Lesson 13: Method overriding & polymorphism
All animals speak — but each differently. When a child class defines a method with the same name as the parent, its version wins: that's overriding. And when the same call on different objects yields different behavior — that's polymorphism, OOP's most elegant idea.
A choir where every animal gets the same instruction — "speak!" — and the dog barks, the cat meows, the snake hisses. One instruction, different performances.
- method overriding
- A child class defining a method with the same name as the parent — and its version is the one that runs.
- polymorphism
- The same method call on objects of different classes — each responding its own way.