Polymorphism: Polymorphism means the ability to take more than one form. Polymorphism is Greek word; Poly means many, and morphism means form- many form. And form means function, many functions it means many methods.
Polymorphism uses methods to perform different tasks. This allows us to perform a single action in different ways.
2 types of Polymorphism:
A] Compile Time [Method Overload]
Method overload means same method name, but different parameters.
Method overload possible with in Single class
Static method allows to overload
Final method allows to overload
Both methods must have different arguments
The number of arguments, sequence and type of arguments is different
The Java Compiler handles Compile-time Polymorphism.
B] Run Time [Method Override]
Method override means same method name and same parameters.
Method Override never possible with in single class, we must need to use Inheritance concept.
Static method can’t allow to override
Final method can’t allow to override
The number of arguments, sequence and type of arguments is same
JVM handles the Runtime polymorphism.