Polymorphism in Java
Polymorphism in Java
Polymorphism means "many forms". In Java, the same method can perform different actions depending on the object or parameters used.
Java supports two main types of polymorphism:
- Compile-time Polymorphism (Method Overloading)
- Runtime Polymorphism (Method Overriding)
Video Explanation

Method Overloading
Method Overloading means creating multiple methods with the same name in the same class but with different parameters.
The method performs similar tasks in different ways depending on the number or type of arguments passed.
It is called compile-time polymorphism because the compiler decides which method to call during compilation.
For example:
add(int a, int b)
add(int a, int b, int c)
Both methods have the same name but different parameters. It is an example of compile-time polymorphism.