MCQs – C++ Inheritance

C++ inheritance mcq with answers and explanation. 50% of the objective questions are asked in interviews and rest are to cover C++ inheritance concepts.

Q)base class and derived class relationship comes under

  1. Inheritance
  2. Polymorphism
  3. encapsulation
  4. None

Answer : 1

Explanation: Base class and derived class come under inheritance, one of the C++ oops principle. Also, it is known as parent child relationship.

Q) C++ Inheritance relationship is

  1. Association
  2. Is-A
  3. Has-A
  4. None

Answer: 2

Explanation: IS A Relationship is related to inheritance in C++.
Lets consider a relation ship between classes i.e. Dog IS A Animal, Apple IS A Fruit, Car IS A Vehicle etc. Here, IS A relationship is valid, but, if we say Animal IS A Dog, then it is wrong. So, Animal class should be the base class and Dog class will be the derived class.

Q) Types of inheritance in C++ are

  1. Multilevel
  2. Multiple
  3. Hierarchical
  4. All the above

Answer: 4

Explanation: All are types of inheritance relationship in C++ oops.
Multilevel Inheritance: When a class is derived from a class which is also derived from another class.
Multiple Inheritance: A class inherits multiple class. or say, A class has more than one base class.
Hierarchical Inheritance: When multiple classes derived from a same base class.

Q) Inheritance allow in C++ Program?

  1. Class Re-usability
  2. Creating a hierarchy of classes
  3. Extendibility
  4. All

Answer: 4

Explanation: Advantage of inheritance are like re-usability- You can re-use existing class in a new class that avoid re-writing same code and efforts.
We can make an application easily extensible.

Q) Functions that can be inherited from base class in C++ program

  1. Constructor
  2. Destructor
  3. Static function
  4. None

Answer: 4


In C++, constructor and destruction of a class cannot be inherited to derived class. However, when we create the object of derived class then constructor of the base class is called automatically. You can read order of execution of constructors and destructors call in c++ inheritance.

Static function is not the part of an object, Hence, it cannot be inherited in derived classes. Note that all the class member functions that are the part of an object, only they can be inherited. Read what is static function in C++ programming

Related Posts