juniorOOP

What is inheritance in OOP?

Updated May 17, 2026

Short answer

Inheritance allows a class to derive properties and behavior from another class.

Deep explanation

It enables code reuse and hierarchical relationships between classes using parent-child structures.

Real-world example

Dog inherits general behavior from Animal like eating and sleeping.

Common mistakes

  • Overusing inheritance instead of composition.

Follow-up questions

  • What is single vs multiple inheritance?
  • What is method overriding?

More OOP interview questions

View all →