Polymorphism means "many forms." It allows the same method name to perform different actions depending on the object.
This is a key concept in OOP that works closely with inheritance.
Method overriding allows a subclass to provide its own implementation of a method defined in the parent class.
The method name and parameters must be the same, but the behavior can change.
You can use a parent class reference to point to a child object. This is where polymorphism becomes powerful.
The method that runs depends on the actual object type, not the reference type.
Method overloading allows multiple methods with the same name but different parameters.
Java decides which method to use based on the arguments passed.
Overriding is resolved at runtime based on the object type. Overloading is resolved at compile time based on method signatures.
Polymorphism allows you to write flexible and reusable code by working with general types instead of specific ones.
Create Shape, Circle, and Rectangle classes with overridden draw() methods.