1.
Can struct be used as Base class for inheritance?
(a) Yes
(b) No

Answer
(a) yes because struct has by default public specifier which can act as base class for our program

2.
The derivation of Child class from Base class is indicated by ____ symbol.
(a) ::
(b) :
(c) ;
(d) |

Answer
(b)
class baseClass
{
// Implementaion here
};
class deriveClass: public baseClass
{
// Implementaion here
};

3.
Reusability of the code can be achieved in CPP through ______
(a) Polymorphism
(b) Encapsulation
(c) Inheritance
(d) Both a and c

Answer
(c) Reusability is the main feature of CPP. Reusability of the code can be achieved in CPP through inheritance. Reusability is the use of existing code the development of software. By the use of inheritance you can use base class data into derived class.

4.
class X, class Y and class Z are derived from class BASE. This is ______ inheritance.
(a) Multiple
(b) Multilevel
(c) Hierarchical
(d) Single

Answer
(c) If class X, class Y and class Z are derived from class BASE. Then it is called as Hierarchical inheritance.

5.
During a class inheritance in CPP, if the visibility mode or mode of derivation is not provided, then by default visibility mode is ___________.
(a) public
(b) protected
(c) private
(d) Friend

Answer
(c) In inheritance if the visibility mode or mode of derivation is not provided, then by default visibility mode is private.

6.
In case of inheritance where both base and derived class are having constructors, when an object of derived class is created then___________ .
(a) constructor of derived class will be invoked first
(b) constructor of base class will be invoked first
(c) constructor of derived class will be executed first followed by base class
(d) constructor of base class will be executed first followed by derived class

Answer
(d) Constructor of base class will be executed first followed by derived class means constructors are executed in their order of derivation. Destructors are executed in reverse order of derivation.

7.
In Multipath inheritance, in order to remove duplicate set of records in child class, we ___________ .
(a) Write Virtual function in parent classes
(b) Write virtual functions is base class
(c) Make base class as virtual base class
(d) All of these

Answer
(c) In Multipath inheritance, in order to remove duplicate set of records in child class, we Make base class as virtual base class.

8.
When a base class is privately inherited by the derived class, then_____________
(a) protected members of the base class become private members of derived class
(b) public members of the base class become private members of derived class
(c) both a and b
(d) only b

Answer
(c) When a base class is privately inherited by the derived class, then protected members of the base class become private members of derived class and public members of the base class become private members of derived class.

9.

What is the syntax of inheritance of class?

(a) class name
(b) class name : access specifer
(c) class name : access specifer class
(d) None of the mentioned

Answer
(c) class name : access specifer class name

10

How many types of inheritance are there in c++?

(a) 2
(b) 3
(c) 4
(d) 5

Answer
(d) There are five types of inheritance in c++. They are single, Multiple, Hierarchical, Multilevel, Hybrid
Inheritance
Tagged on: