Monday 25 February 2013

Types of Polymorphism

Polymorphism is divided into 2 categories
  • Compiletime Polymorphism (also called as Static Polymorphism or Early Binding)
  • Runtime Polymorphism (also called as Non-Static Polymorphism or Late Binding)
        In the first case the object of the class will identify for a particular method call which polymorphic method has to be executed and binds the method call with its method definition and executes this method in runtime but only the method will be bound. This type of binding takes place in Overloading because in overloading we have multiple methods with same name but different signature so each method is unique to itself so while binding the method definition we can identify the unique keyword.
       In the second case ie Runtime Polymorphism the object of a class recognizes which polymorphic method it has to call in runtime and this kind of identification takes pace in Overriding and Hiding as there are multiple methods with the same name and same signature with both the cases so that  the object will identify which exact method has to be executed in runtime only being on the hierarchy of the class.

No comments:

Post a Comment