What is the main purpose of inheritance in OOP?

2025

What is the main purpose of inheritance in OOP?

Answer: C. To establish a parent-child relationship between classesConcept: Inheritance is the core OOP mechanism by which a new class, called the derived (child) class, is defined in terms of an already-existing class,…

  1. A.

    To create instances of classes

  2. B.

    To prevent data abstraction

  3. C.

    To establish a parent-child relationship between classes

  4. D.

    To define exceptions

Attempted by 216 students.

Show answer & explanation

Correct answer: C

Concept: Inheritance is the core OOP mechanism by which a new class, called the derived (child) class, is defined in terms of an already-existing class, called the base (parent) class. The child class automatically acquires the parent's accessible fields and methods, establishing a hierarchical, reusable "is-a" relationship between the two classes.

Application: Applying this to the question, among the four choices only "establish a parent-child relationship between classes" matches what inheritance actually does: a subclass such as Dog inheriting from a superclass such as Animal gains Animal's members without rewriting them, forming exactly this parent-child hierarchy.

Contrast:

  • Creating instances of a class is done through instantiation (a constructor call, e.g. new Dog()), a distinct OOP mechanism; inheritance does not itself produce objects.

  • Inheritance does not prevent data abstraction; abstraction is achieved through abstract classes and interfaces, and base classes are commonly used to provide that abstraction, so inheritance supports it rather than blocking it.

  • Defining exceptions is handled by a language's exception-handling constructs (such as try/catch/throw), a separate feature unrelated to how one class relates to another through inheritance.

Cross-check: The same signature appears across languages: Java's extends, C++'s class Derived : public Base, and Python's class Child(Parent) all express inheritance this way, confirming that its defining purpose is to establish this class hierarchy, not instantiation, abstraction-blocking, or exception handling.

Explore the full course: Bpsc

Loading lesson…