Polymorphism in Java means a subclass, though having its own unique behavior, can also share some functionality of its parent class. It is a part of (Object Oriented Programing) OOPs concept that allows object of various types to define a common interface of operations.
Any object that satisfies more than one IS-A relationship is polymorphic. In Polymorphism, common interface is used while writing code. Single polymorphism is achieved by method overriding while multiple polymorphism is when an abstract class uses another abstract class.
In simple words Polymorphism in Java helps an object to decide which method implementation to be executed after receiving a method call.
If we use a common interface it becomes easy to change code to support new implementation.
Polymorphism in Java can be seen through Inheritance, method overloading and method overriding.
In Compile-Time polymorphism uses method signatures to determine which among various methods to be executed after compilation to the byte code.
In Run-Time polymorphism, achieved through overridden methods, a computer does not know which methods to execute till the run time.
Posted on: September 3, 2013 If you enjoyed this post then why not add us on Google+? Add us to your Circles