Consider the following inheritance in C++ class BASE: class BASE { int B1;…

2022

Consider the following inheritance in C++ class BASE: class BASE { int B1; protected: int B2; public:

  1. A.

    B2 → protected, FUNB() → public

  2. B.

    B2 → protected, FUNB() → protected

  3. C.

    B2 → public, FUNB() → public

  4. D.

    B2 → private, FUNB() → protected

Attempted by 150 students.

Show answer & explanation

Correct answer: A

In public inheritance in C++: Public members of the base class remain public in the derived class. Protected members of the base class remain protected in the derived class. Private members of the base class are not accessible in the derived class. Here: B2 is protected in BASE → remains protected in DERIVED. FUNB() is public in BASE → remains public in DERIVED.

Explore the full course: Uppsc Polytechnic Lecturer 2025 Cs