🎯 1. What is Polymorphism?

Polymorphism = one action, many forms.

Same method name β†’ different behavior depending on object type.

Example:

area() β†’ circle, rectangle, square β†’ each computes area differently.

Two types:

  1. Compile-time polymorphism β†’ Method Overloading
  2. Runtime polymorphism β†’ Method Overriding (today’s topic)

⭐ 2. Why Polymorphism Matters?

βœ” Flexible code

βœ” Cleaner architecture

βœ” Extensible design

βœ” Powerful abstraction

βœ” Makes frameworks possible (Spring, Hibernate, JDBC)

Real use:

List list = new ArrayList();
list = new LinkedList(); // polymorphism

🧠 3. Runtime Polymorphism (Dynamic Dispatch)