The BASE for JAVA LEARNING

by
PRO
FE S
S OR

P O L Y M O R P H I S M
AN OBJECT-ORIENTED PILLAR
Many define Polymorphism as "many forms" but in Object-Oriented Language, POLYMORPHISM refers to dynamic-binding implementation of one method among many of the same kind.
Only the code of one distinctive method is executed at a time. The method executed is determined by an association of an object pointer at running time.
Polymorphic methods have the same names and use the same type of parameters and values returned. The code for each method is not the same.
Polymorphic methods are defined in distinctive classes, and the method is differentiated during execution, by virtue of an object reference.
Polymorphism is useful when implemented by an outside class.
Why POLYMORPHISM:
No need to overload methods.
Code efficiency is enhanced, as branching is made at execution time.
JAVA ways of implementing Polymorphism:
By the use of Inheritance, with methods defined in sibling classes all with a common parent.
By the use of Interface, with methods defined in classes which conform to a common interface.