Inheritance MCQs

Inheritance MCQs

Try to answer these 20+ Inheritance MCQs and check your understanding of the Inheritance subject.
Scroll down and let's begin!

1: Reusability of the code can be achieved in CPP through:

A.   None

B.   Inheritance

C.   Encapsulation

D.   Polymorphism

2:

When base class is derived in protected mode, then______________.

1. public members of base class become private members of derived class

2. public members of base class become protected members of derived class

3. public members of base class become public members of derived class

4. protected members of base class become protected members of derived class

5. protected members of base class become private members of derived class

6. protected members of base class become public members of derived class


A.  

 Only 2, 6

B.  

 Only 1, 5


C.  

 Only 1, 6


D.  

 2 , 4


3: The derivation of Child class from Base class is indicated by ____ symbol.

A.   :

B.   /

C.   ::

D.   ;

4: Can we pass parameters to base class constructor though derived class or derived class constructor?

A.   No

B.   Yes

5: If the derived class is struct, then default visibility mode is_______.

A.   Protected

B.   Public

C.   Private

D.   Struct can’t inherit class

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 executed first followed by base class

B.   Constructor of derived class will be invoked first

C.   Constructor of base class will be invoked first

D.   Constructor of base class will be executed first followed by derived class

7: Private members of the class are not inheritable.

A.   False

B.   True

8: What is difference between protected and private access specifiers in inheritance?

A.   Private member is not inheritable and not accessible in derived class

B.   Both are inheritable but protected is not accessible in the derived class

C.   Protected member is inheritable and also accessible in derived class

D.   Both are inheritable but private is accessible in the derived class

9: Can struct be used as Base class for inheritance ?

A.   No

B.   Yes

10: Class X, class Y and class Z are derived from class BASE. This is _____________ inheritance.

A.   Multilevel

B.   Single

C.   Hierarchical

D.   Multiple

11:

In case of inheritance where both base and derived class are having constructor and destructor, then which if the following are true?

1. Constructors are executed in their order of derivation

2. Constructors are executed in reverse order of derivation

3. Destructors are executed in their order of derivation

4. Destructors are executed in reverse order of derivation


A.  

 Only 2, 3


B.  

 Only 1 , 3


C.  

 Only 2 ,4


D.  

 Only 1 , 4


12: When a base class is privately inherited by the derived class, then_______________.

A.   None

B.   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

C.   Protected members of the base class become private members of derived class

D.   Public members of the base class become private members of derived class

13: 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.   Friend

D.   Private

14: If base class has constructor with arguments, then it is ________________ for the derived class to have constructor and pass the arguments to base class constructor.

A.   Compiler dependent

B.   Mandatory

C.   Optional

D.   Error

15: In Multipath inheritance, in order to remove duplicate set of records in child class, we___________.

A.   All

B.   Write virtual functions is base class

C.   Make base class as virtual base class

D.   Write Virtual function in parent classes

16: ____ is the ability to use the same expression to denote different operations.

A.   Inheritance

B.   Encapsulation

C.   Polymorphism

D.   Composition

17: ________ is commonly used to extend a class, or to give it additional capabilities.

A.   Inheritance

B.   Privacy

C.   The constructor

D.   The destructor

18: A class that represents the most general entity in an inheritance hierarchy is called a/an ____.

A.   Default class

B.   Superclass

C.   Subclass

19: A derived class always ____ case or instance of the more general base class.

A.   Is-a

B.   True

C.   False

D.   Class

20: Inheritance is an example of a(n) ____ relationship.

A.   Is-a

B.   Has-a

C.   Both A & B

D.   None of the above

21: Look at the following code. the method in line ________ will override the method in line ________.

A.   Line 4, Line 10

B.   Line 1, LIne 4

C.   Line 0, Line 4

D.   None of these

22: According to the following punnett square, the female genotype is _____.

A.   TT

B.   Tt

C.   Tt

D.   Homozygous

E.   Tt or heterozygous