Which of the following is the most fundamental benefit provided by inheritance…

2023

Which of the following is the most fundamental benefit provided by inheritance in object-oriented programming?

  1. A.

    Faster execution of programs

  2. B.

    Enhanced code readability

  3. C.

    Increased code reusability

  4. D.

    Simplified debugging process

  5. E.

    Improved memory management

Attempted by 76 students.

Show answer & explanation

Correct answer: C

Concept

In object-oriented programming, inheritance is the mechanism by which a new class (the child/derived class) acquires the attributes and behaviours of an existing class (the parent/base class). Its defining purpose is to let one class build upon another so that common code is written once in the base class and shared by every class that derives from it.

Application

Because the derived class automatically obtains the members of the base class, the same logic does not have to be re-written in each subclass. This direct sharing of an existing class's code with its descendants is exactly what is meant by increased code reusability — the most fundamental benefit inheritance provides. Every other advantage that inheritance may incidentally bring flows from this core ability to reuse a base implementation.

Why the other choices are not the fundamental benefit

  • Faster execution of programs: inheritance is a compile-time/source-organisation feature; at runtime, dynamic dispatch through inherited methods can add a small overhead rather than speed code up, so performance is not its purpose.

  • Enhanced code readability: cleaner reading can be a side effect of good class design, but deep inheritance hierarchies can equally hurt readability — it is not the mechanism's defining goal.

  • Simplified debugging process: shared base code can actually make a fault harder to localise across a hierarchy, so easier debugging is not a guaranteed or fundamental outcome.

  • Improved memory management: inheritance describes relationships between classes, not how objects are allocated or freed; memory handling is governed by the runtime, not by inheritance.

Conclusion

The principle that defines inheritance is sharing and extending an existing class's code, which is precisely increased code reusability.

Explore the full course: Ibps So It Mains

Loading lesson…