Saturday, February 16, 2013

[Java] What is polymorphism? What is dynamic binding?

Polymorphism means that a variable of a supertype can refer to a subtype object. It’s the ability of an object to take on many forms. The most common use of polymorphism in OOP occurs when a parent class reference is used to refer to a child class object. Any Java object that can pass more than one IS-A test is considered to be polymorphic.

When compiler is not able to resolve the call/binding at compile time, such binding is known as Dynamic or late Binding. Overriding is a perfect example of dynamic binding as in overriding both parent and child classes have same method. Thus while calling the overridden method, the compiler gets confused between parent and child class method(since both the methods have same name).


Remarks
Text provided above does not means is the model answer, and it's was posted here for an reference to somebody who interested the related knowledge only. if there is something incorrect, please leave a comment so that i can correct it or for others viewer to have an better reference, if you want know more about this topic and where is the question, concept or answer from, you can reference from information provided under the reference sub-title.

Reference:
1) Introduction to Java Programming, Y. Daniel Liang, 11.17
2) http://beginnersbook.com/2013/04/java-static-dynamic-binding/

No comments :

Post a Comment