Unit 12 · overview

Unit 12: Inheritance, Overriding, and Dynamic Dispatch

Inheritance is useful when a subtype can genuinely stand in for a broader type while preserving its promises.

It is dangerous when used merely to reuse a few lines.

This unit covers:

  • extends and subtype relationships;
  • inherited members;
  • overriding;
  • runtime dynamic dispatch;
  • substitutability;
  • composition-versus-inheritance tradeoffs.

Checkpoint 4 asks you to defend the relationship, not just make a class hierarchy compile.