Inheritance MCQs: 12 Solved Questions on Code Reuse and Class Hierarchies

Solve 12 inheritance MCQs, then use clear explanations to separate hierarchy shape, access rules, assignment compatibility, constructor order and method lookup.

KnowledgeGate Team

Exam prep & CS education

Updated 16 Aug 20268 min read

Inheritance questions often look like definition recall, but marks are lost when is-a, code reuse, access conversion, constructor order and method lookup are treated as the same rule. Choose an option first, then justify it with one inheritance rule before reading the explanation. Treat each item as a rule test, not trivia.

Inheritance sits inside the wider Coding & DSA Courses for Placements collection, and the topic carries over 50 solved questions in all. Questions 1, 2, 9 and 11 are practised from the Inheritance PYQ Questions hub; the other eight link to their own solved-question page.

1. Inheritance rules to fix before the MCQs

Concept

Meaning

Inheritance

Deriving a new class from an existing class

is-a

A subtype relationship

Hierarchical inheritance

One base with two or more direct derived classes

Multiple inheritance

One derived class with two or more direct bases

A has-a relationship is composition, not inheritance. Let Employee store id = 17 and name = "Asha". SalariedEmployee inherits them and adds monthlyPay = 42000. ContractEmployee inherits them and adds dailyRate = 1800 and daysWorked = 22.

The contract employee's pay is computed step by step:

  1. Daily rate = 1800.

  2. Days worked = 22.

  3. Pay = 1800 x 22 = 39600.

Both children reuse id and name. One parent with two children is hierarchical inheritance. Neither child has two parents, so it is not multiple inheritance.

Two language rules will matter later. In C++, protected inheritance converts inherited public and protected members to protected, while base private members remain inaccessible. Constructors run from base to derived, so an object at the end of an A -> B -> C chain is constructed in A, B, C order.

2. Inheritance MCQs 1-3: reusability and hierarchical classification

Question 1, DSSSB 2022

What may be achieved by the inheritance feature of object-oriented programming?

  • A. Security

  • B. Robustness

  • C. Reusability

  • D. Abstraction

Correct answer: C. Reusability.

Inheritance reuses base-class data and behaviour while the child specialises changes. Security comes from access control and abstraction hides detail, so neither is primary.

Question 2, UPPSC 2022

Which of the following supports the concept of hierarchical classification?

  • A. Polymorphism

  • B. Encapsulation

  • C. Abstraction

  • D. Inheritance

Correct answer: D. Inheritance.

Inheritance creates parent-child links from a general type to specialised types. That structure directly supports hierarchical classification.

Question 3, NVS 2017

The following is the correct interpretation of Hierarchical Inheritance.

  • A. one base class with one derived class

  • B. more than one generation of classes

  • C. more than one base classes with one derived class

  • D. one base class with more than one derived classes

Correct answer: D. one base class with more than one derived classes.

One base with several direct children is hierarchical inheritance. A is single, B multilevel, and C multiple inheritance. View the solved question.

3. Inheritance MCQs 4-6: parent counts, interfaces and subtyping

Question 4, KVS 2017

Which one of the following most accurately describes "multiple inheritance"?

  • A. When a child class has both an "is-a" and a "has-a" relationship with its parent class.

  • B. When two classes inherit from each other.

  • C. When a base class has two or more derived classes.

  • D. When a child class has two or more parent classes.

Correct answer: D. When a child class has two or more parent classes.

Count one child's direct bases. Two or more mean multiple inheritance, while option C is hierarchical inheritance. View the solved question.

Question 5, Beltron Programmer Shift-2 2025

Which of the following statements best captures the behaviour of interfaces when one interface extends another in object-oriented design?

  • A. An interface can only extend a single class, but not another interface.

  • B. An interface cannot be extended or implemented further once defined.

  • C. When one interface extends another, it inherits all constants and method declarations from the parent interface.

  • D. Interfaces can implement other interfaces to share functionality.

Correct answer: C. When one interface extends another, it inherits all constants and method declarations from the parent interface.

Interfaces inherit from interfaces using extends, receiving the parent's contract. Classes implement interfaces, so D uses the wrong relationship. View the solved question.

Question 6, UGC NET December 2015

Consider the following two statements:

(a) A publicly derived class is a subtype of its base class

(b) Inheritance provides for code reuse

Which of the following statements is correct?

  • A. Both statements (a) and (b) are correct

  • B. Neither of the statements (a) and (b) are correct

  • C. Statement (a) is correct and (b) is incorrect

  • D. Statement (a) is incorrect and (b) is correct

Correct answer: A. Both statements (a) and (b) are correct.

Public derivation preserves the public is-a relation, and a derived class reuses whatever base implementation it can access. Both statements hold, so A is the only option that fits. View the solved question.

4. Inheritance MCQs 7-9: C++ access and assignment compatibility

Question 7, UGC NET December 2019

Let A be the base class in C++ and B be the derived class from A with protected inheritance. Which of the following statement is false for class B?

  • A. Member function of class B can access protected data of class A

  • B. Member function of class B can access public data of class A

  • C. Member function of class B cannot access private data of class A

  • D. Object of derived class B can access public base class data

Correct answer: D. Object of derived class B can access public base class data.

Protected inheritance makes inherited public and protected members protected. B methods can use them, outside code cannot, and base private data remains inaccessible. View the solved question.

Question 8, UGC NET June 2015

When the inheritance is private, the private methods in base class are _____ in the derived class (in C++).

  • A. inaccessible

  • B. accessible

  • C. protected

  • D. public

Correct answer: A. inaccessible.

Base private members stay inaccessible in a derived class. Private derivation changes inherited public and protected members to private without exposing base private methods. View the solved question.

Question 9

A class D is derived from a class B, b is an object of class B, d is an object of class D, and pb is a pointer to class B object. Which of the following assignment statement is not valid?

  • A. d = d;

  • B. b = d;

  • C. d = b;

  • D. *pb = d;

Correct answer: C. d = b;.

d = d is valid. b = d and, assuming valid pb, *pb = d copy the base portion and may slice state. A base object cannot be assigned to a derived object, so d = b is invalid.

5. Inheritance MCQs 10-12: constructor order and method lookup

Question 10, RPSC Programmer - P2 2024

If A is a superclass, B is a subclass of A, and C is a subclass of B, in what order are the constructors of these classes called? (Assume the standard automatic superclass-constructor invocation used in mainstream OOP languages such as C++, Java and C#.)

  • A. A, C, B

  • B. A, B, C

  • C. C, A, B

  • D. C, B, A

Correct answer: B. A, B, C.

Construction initialises inherited base portions first, producing A, B, C. Destruction uses the reverse order, but is not asked. View the solved question.

Question 11

What will be the output of the following Java program?

class First
{
    public First() { System.out.println("a"); }
}

class Second extends First
{
    public Second() { System.out.println("b"); }
}

class Third extends Second
{
    public Third() { System.out.println("c"); }
}

public class MainClass
{
    public static void main(String[] args)
    {
        Third c = new Third();
    }
}
  • A.

  a
  b
  c
  • B. error

  • C. c

  • D.

  c
  b
  a

Correct answer: A. a, then b, then c on separate lines.

new Third() runs the implicit super() chain. First, Second and Third print a, b and c in base-to-derived order.

Question 12, Hexaware and CoCubes 2023

What is the output of the following C++ program?

#include <iostream>
using namespace std;

class P {
public:
    void print()
    { cout << " Inside P::"; }
};

class Q : public P {
public:
    void print()
    { cout << " Inside Q"; }
};

class R : public Q {
};

int main(void)
{
    R r;
    r.print();
    return 0;
}
  • A. 0

  • B. Error

  • C. Inside Q

  • D. Inside P

Correct answer: C. Inside Q.

R has no print, so lookup finds the nearest definition in Q and stops before P. Direct call on an R object makes virtual dispatch irrelevant. View the solved question.

6. Inheritance traps these 12 questions expose

Trap

Questions to revisit

Reuse versus other OOP features

Q1 and Q6

One parent or many parents

Q2, Q3 and Q4

Interface and subtype contracts

Q5 and Q6

Access after derivation

Q7 and Q8

Construction and lookup through a chain

Q10, Q11 and Q12

Q9 adds a direction trap. Upcasting is allowed, though value copying may slice derived state. Down-assigning a plain base object is invalid.

Use a 20-second routine: draw class arrows, count direct parents and children, note access, then trace base-to-derived construction or nearest-class lookup. Review OOP for Teaching CS Exams: Classes and Inheritance for the broader sequence. Continue with String Handling in Java: Pool, Immutability, Interview Questions as the next Java concept-and-question set.

7. Inheritance MCQs: the next practice step

Redo Questions 3, 4, 7, 9, 11 and 12 without viewing the answers. Together they test hierarchy shape, multiple bases, access conversion, assignment direction, constructor order and nearest-base method lookup. For a sequenced route that places inheritance beside the rest of core and advanced Java, use the Java Course: Concepts, MCQs & Coding Questions.

The short version is simple. Inheritance creates an is-a relationship and can reuse accessible code. Parent count identifies the hierarchy, access rules control visibility, constructors run from base to derived, and member lookup starts at the most specific available class. Retest until you can name the governing rule before checking an option.