The child who cooks differently

Method Overriding

The analogy

Your family recipe says "boil the pasta". You keep the recipe name but do it your own way — you fry it instead. Same instruction from the outside, different behaviour inside. That is overriding.

Visualizer

Which version actually runs

step 1 / 7
TownhouseHouseObject

A reference DECLARED as House is holding an object whose ACTUAL type is Townhouse.const h: House = new Townhouse()

class House:
    def open_door(self):  return "creak"

class Townhouse(House):
    def open_door(self):  return "buzz"

h: House = Townhouse()
h.open_door()      # "buzz"
# resolved by the OBJECT, not the annotation
Check yourself

A House reference points to a Townhouse. Which openDoor() runs?