Tuesday, April 10, 2007
What is Polymorphism/Late Binding?
Subscribe to:
Post Comments (Atom)
World of tricky Core Java Q&A(Java SE),Java EE and Open source technologies like Struts,Hibernate,Spring,Velocity etc
Disclaimer
Interview Questions On Java,Java EE Copyright © 2012
4 comments:
The ability to take more than one form is called Polymorphism, sigle function may handle different objects.
Super-class's instance variable can point to objects of any of its sub-class's object at run-time. IE we can assign object of any sub-class to the instance variable of super-class at run-time. IE instance variable of a super-class can know where to point only at run-time and not at compile time. This is called Late Binding.
It can also be treated as Polymorphism, as same instance variable of super-class can point objects of different sub-classes [one at a time] thus having different forms.
Polymorphism means single name and many forms.
method overloading is the example for polymorphism.
Single function have the ability to perform the different different task is called polymorphism (one name multiple forms).
Type of polymorphism
- compile time and
- run time polymorphism.
we can achieve compile time polymorphism through function overloading and run time polymorphism through function overriding.
Post a Comment