Design patterns·Objects, messages and the principles
the method that runs is chosen by what the object actually is at that moment, not by the type the variable was declared with.
Dynamic dispatch
Also calledvirtual dispatch, late dispatch, runtime dispatch
The runtime lookup that decides which implementation a call lands on, based on the receiving object rather than the compile-time type. It is what makes polymorphism work and what makes a call slightly slower and harder for a compiler to inline. Knowing it is dispatch rather than magic is what lets you reason about why a base-class method calling an overridden method runs the subclass version — the source of most surprises in a deep hierarchy.