In object-oriented programming, a subclass inherits all members of its base…

2025

In object-oriented programming, a subclass inherits all members of its base class except:

  1. A.

    Public members from the base class

  2. B.

    Protected members from the base class

  3. C.

    Private members from the base class

  4. D.

    Static members from the base class

  5. E.

    Friend functions of the base class

Attempted by 3 students.

Show answer & explanation

Correct answer: C

Concept

Inheritance lets a derived (sub) class reuse the definition of a base class. An access specifier — public, protected, private — controls who may use a member: public members are usable everywhere, protected members are usable inside the class and its descendants, and private members are usable only inside the class that declares them. The governing rule: a subclass does not inherit access to the private members of its base class — they stay encapsulated in the base and cannot be used directly by the derived class.

Applying it here

Check each kind of member against that rule:

  • public and protected members are inherited and stay usable by the subclass.

  • static members are inherited too — one shared copy belongs to the class hierarchy, so the subclass can use it.

  • private members are the exception: the subclass does not inherit access to them and cannot use them directly. (A public/protected accessor exposed by the base can still reach that data indirectly, but the private member itself is not usable by the subclass.)

So among the kinds of members, the one a subclass cannot inherit and use is the private members of the base class.

Why not friend functions

A friend function is granted access to a class's private and protected parts, but it is not a member of the class at all. Since the question asks which member is not inherited, a friend function lies outside the set of members and is never inherited regardless — so it cannot be the intended answer to a question about members.

Explore the full course: Ibps So It Mains

Loading lesson…