POLYMORPHISM helps us to learn Right Message At Right Time !!!

         

POLYMORPHISM helps us to learn Right Message At Right Time !!! 

Object Oriented Programming Language is one of the most important word in today’s programming world.  OOPS exists in so many programming languages like Java, Python, JavaScript, C++, Php. So without understanding the idea behind this ,one cannot improve any of these languages. And our OOPS is mostly inter-related  with our day to day life. Lets see how this is related.

Object -> It is an instance of a class, Object is an copy of that class and  Instance is a variable that holds the memory address of the object.

Polymorphism

Polymorphism is one of the oops concept “

Ability to have different forms ie: Function with same name and different parameters.

There are Two ways to achieve Polymorphism ,

  • Method Overloading – Static polymorphism
  • Method Overriding – Dynamic polymorphism

We will see overloading first !

Method Overloading!

1 . Consider a Human being , (he/she) behaves  like a customer in a super market, behaves like a passenger while travelling, behaves like a child when they are with their parents and so on.

  1. One person(he/she) may have 2 or more phone numbers.

Static polymorphism is achieved by method overloading.ie  during compile time.

Eg : Here is a class named SimpleCalulator  and it consists of two methods add(int a ,int b) which has two integer parameters and another method named int add(int a,int b,int c) which has three integer parameters. Then object is created for class and (functions/methods ) are called with values , and this is static polymorphism. During our compile time values are passed to the resp function.

OUTPUT:

  • Difference with type given
  • Difference with size given

->This we call as Method overloading.

 

Method Overriding!

 

  1. Here is an real time example for overriding, consider a Bank and now a days there are number of banks , one common thing about all the banks is INTEREST. Every bank possess different amount of interest for various properties but Interest is one common thing.

 

Here getRateOfInterest() method  is common for all banks as I said before , we get different outputs with different classes with same function name. This is Overriding.

Hope this blog inspires you to embrace change and grow. Whether you are an XPLORER or not, feel free to glance through our blogs and help us guide and support you in your voyage to success. Happy Learning!

0 responses on "POLYMORPHISM helps us to learn Right Message At Right Time !!!"

Leave a Message

Your email address will not be published. Required fields are marked *

About Xplore IT Corp

XIC is home to several global certified trainers who are subject matter experts in their respective domains. XIC has Vast experienced resources who are top experts including that of Microsoft, Cisco, Oracle, VMware, Red Hat, Novell, EC Council, Adobe, among others.

top
© Xplore IT Corp 2017. All rights reserved. Designed by ProPlus Logics
X