Inheritance - C++ (MCQ) questions and answers

1)   Can we pass parameters to base class constructor though derived class or derived class constructor?
- Published on 19 Oct 15

a. Yes
b. No
Answer  Explanation 

ANSWER: Yes

Explanation:
No explanation is available for this question!


2)   Private members of the class are not inheritable.
- Published on 19 Oct 15

a. True
b. False
Answer  Explanation 

ANSWER: False

Explanation:
No explanation is available for this question!


3)   In case of inheritance where both base and derived class are having constructors, when an object of derived class is created then___________ .
- Published on 19 Jul 15

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  Explanation 

ANSWER: constructor of base class will be executed first followed by derived class

Explanation:
No explanation is available for this question!


4)   Can struct be used as Base class for inheritance ?
- Published on 19 Jul 15

a. Yes
b. No
Answer  Explanation 

ANSWER: Yes

Explanation:
No explanation is available for this question!


5)   If the derived class is struct, then default visibility mode is _______ .
- Published on 19 Jul 15

a. public
b. protected
c. private
d. struct can’t inherit class
Answer  Explanation 

ANSWER: public

Explanation:
No explanation is available for this question!


6)   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.
- Published on 17 Jul 15

a. Optional
b. Mandatory
c. Compiler dependent
d. Error
Answer  Explanation 

ANSWER: Mandatory

Explanation:
No explanation is available for this question!


7)   In Multipath inheritance, in order to remove duplicate set of records in child class, we ___________ .
- Published on 17 Jul 15

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  Explanation 

ANSWER: Make base class as virtual base class

Explanation:
No explanation is available for this question!


8)   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

- Published on 17 Jul 15

a. Only 2 ,4
b. Only 1 , 3
c. Only 1 , 4
d. Only 2, 3
Answer  Explanation 

ANSWER: Only 1 , 4

Explanation:
No explanation is available for this question!


9)   When a child class inherits traits from more than one parent class, this type of inheritance is called _______________ inheritance.
- Published on 17 Jul 15

a. Hierarchical
b. Hybrid
c. Multilevel
d. Multiple
Answer  Explanation 

ANSWER: Multiple

Explanation:
No explanation is available for this question!


10)   What is the difference between protected and private access specifiers in inheritance?
- Published on 17 Jul 15

a. private member is not inheritable and not accessible in derived class.
b. protected member is inheritable and also accessible in derived class.
c. Both are inheritable but private is accessible in the derived class.
d. Both are inheritable but protected is not accessible in the derived class.
Answer  Explanation 

ANSWER: protected member is inheritable and also accessible in derived class.

Explanation:
No explanation is available for this question!


1 2