QamoosTech
Programming FundamentalsIntermediate

Inheritance

Pronunciationin-HAIR-ih-tans

Definition

When a class reuses the properties and methods of another class and can add or change some of them.

Where you hear it

Object-oriented design and interviews ("composition over inheritance").

Examples

  • AdminUser inherits from User.
  • Deep inheritance chains are hard to maintain.

Common mistake

Using inheritance just to share code. If the relationship is not "is a", prefer composition.