Polymorphism

From JholJhapata
Revision as of 06:15, 15 August 2019 by Admin (talk | contribs)

Polymorphism meaning "one name many forms", which is also referred to as the third pillar of object-oriented programming. "Poly" means many and "morph" means forms. Polymorphism provides the ability to a class to have multiple implementations with the same name.

Types of Polymorphism

Polymorphism

Polymorphism can be static or dynamic. In static polymorphism, the response to a function is determined at the compile time. In dynamic polymorphism, it is decided at run-time.

Static Polymorphism

Static polymorphism is also known as Early Binding. We can achieve this by Method overloading. In overloading, the method / function has a same name but different signatures (types and/or the number of arguments and/or order of arguments). It is also known as Compile Time Polymorphism because the decision of which method is to be called is made at compile time.

Static Polymorphism Example

Dynamic Polymorphism

Dynamic Polymorphism Example