polymorphism real time example

Example 1: what is runtime polymorphism

Runtime polymorphism is a process of which take
cares the overriding method at run time
rather than compile time.
 In method overriding,
a subclass overrides a method with the same 
signature as that of in its superclass. 
During compile time, the check is made 
on the reference type. But, in the runtime,
JVM figures out the object type and would 
run the method that belongs to
that particular object.

Example 2: use of polymorphism in real world

The word polymorphism means having many forms. In simple words, we can define polymorphism as the ability of a message to be displayed in more than one form. Real life example of polymorphism: A person at the same time can have different characteristic. Like a man at the same time is a father, a husband, an employee

Tags:

Java Example