This tutorial is all about Polymorphism in Java.
Polymorphism is 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.
In polymorphism, two things internally process:
- Method Overriding
- Auto upcasting
Together both brings polymorphism. Inheritance is used for polymorphism.
Let’s take one example