POLYMORPHISM

POLYMORPHISM – Definitions, Types

Definitions of Polymorphism

What does Polymorphism mean?

With the modernization and technology pacing up the race we do get very little time to spend in the leisure form. But at the same time the exciting theories and knowledge that is being developed with each and every step increase in the technical field we are getting to know more and more. The great hype that is being carried around today is programming languages which are triggering the interests of people to know more and more and then accordingly we are trying harder to know more about it.

Well as we all know whenever the words programming languages are the ones to take a step into the minds of the user we have to have an idea about the OOP which is the abbreviations of the objected oriented programming and it is that software design which helps us to get acquainted with more of the features and structures that can be used in a data structure.

POLYMORPHISM

So, as the name of our topic suggests polymorphism let us discuss what exactly polymorphism is. Well, it is a concept that can perform a single action in a different way. According to the Greek translation of polymorphism, we come across 2 terms poly which denotes many and morphs that means forms and hence the direct translations go like this.

Polymorphism is basically of 2 types and they are:

Runtime polymorphism
Compile-time polymorphism

In the case of runtime polymorphism, also known as dynamic method dispatch is the one in which an overridden method is called through the reference variable of a superclass. The determination of the method to be called is usually based on the object that is being referred to. Here, a method is overridden not the data members and so the run time polymorphism cannot be achieved by the data members. Though there has been an evolution of a number of different programming languages yet these basic definitions in order for the understanding of our programming language still remains the same. The difference that the languages hold in high or low level is just a way of writing the program in accordance with the way the computer accepts the programs.

In the case of compile-time polymorphism that is also known as static polymorphism and this can be achieved by function overloading or operator overloading. Now let us know about the method overloading that we have been talking about. Well, this is the case when we have multiple methods of same parameters then we can say that these functions are overloaded. They can be overloaded by the change in the number of arguments or/and the change in the types of the arguments. Operator overloading sounds the same the only difference is that java provides an option to the load the functions.

POLYMORPHISM

Compile-time polymorphism includes operator over-riding and method over-riding while runtime polymorphism includes virtual functions. Dynamic one does not even allow the compiler to find the executed method. The JVM needs to do this during the runtime. Within an inheritance hierarchy, the subclasses can override a method of its superclass and it will enable the developer of the subclass to customize or completely replace the attributes of that method. This leads to the creation of polymorphism for both methods implemented by super-class and subclass and share the same names and parameters but provide different kinds of functionality.

POLYMORPHISM

Well now to make our concept of polymorphism clearer let us look at a real-life experience:

We all have different characteristics at the same time. So, let us consider a person having different characteristics at the same time. Just like a man is a father, a son, a brother. So, it has to possess’ different attributes while handling different situations. This is called polymorphism. In the technical world, we can define it is one interface having multiple implementations.

So, this was all that we ever would wish to know about polymorphism while just starting off with a brand-new topic. Though there have been a number of terms that we have to go across while coming to know more about the programming language but we can conclude here by saying that these were the basics of any programming language in order to proceed with the further working. the different languages with their respective uses can be used to create a better version of it yet the base shall still remain the same whenever OOPs are to be taken into account.

(image source google search)

Hi there! Welcome to Information Mania a website where you can find the latest and interesting blogs and articles hope you will like it and support us. As we are growing and learning new things every day and also trying to share that with all of you in our post and blogs. I love to hear your suggestions and ideas in the comments! contact us: [email protected]

Leave a Reply

Your email address will not be published.