This set of Object Oriented Programming (OOPs) using C++ Multiple Choice Questions & Answers (MCQs) focuses on “Hybrid Inheritance”.
1. Which among the following best defines the hybrid inheritance?
a) Combination of two or more inheritance types
b) Combination of same type of inheritance
c) Inheritance of more than 7 classes
d) Inheritance involving all the types of inheritance
Explanation: When more than one type of inheritance are used together, it results in new type of inheritance which is in general known as hybrid inheritance. This may of may not have better capabilities.
2. How many types of inheritance should be used for hybrid?
a) Only 1
b) At least 2
c) At most two
d) Always more than 2
Explanation: There must be combination of at least 2 types of inheritance. The inheritance should be of different type.
3. If single inheritance is used with class A and B. A is base class. Then class C, D and E where C is base class and D is derived from C, then E is derived from D. Class C is made to inherit from class B. Which is the resultant type?
a) Single level
Explanation: The statement represents multilevel inheritance. It is not hybrid since looking at complete idea, one can’t differentiate whether two type of inheritance are used. Hence it is multilevel inheritance.
4. Diamond problem includes ____________________ hybrid inheritance.
a) Hierarchical and Multiple
b) Hierarchical and Hierarchical
c) Multiple and Multilevel
d) Single, Hierarchical and Multiple
Explanation: The diamond problem arises when more than one classes are derived from one class and then those classes are used to derive single clas. Resulting in ambiguity of same functions from each class.
5. If __________________ inheritance is done continuously, it is similar to tree structure.
d) Hierarchical and Multiple
Explanation: Hierarchical inheritance is deriving more than one classes from a base class, it it is done continuously and subsequently, it results forming a tree like structure of classes being linked.
6. Which amongst the following is true for hybrid inheritance?
a) Constructor calls are in reverse
b) Constructor calls are priority based
c) Constructor of only derived class is called
d) Constructor calls are usual
Explanation: The constructors will be called in usual way. First the parent class Constructor and then the derived class Constructors. This is done to initialise all the members properly.
7. Which type of inheritance must be used so that the resultant is hybrid?
Explanation: The use of any specific type is not necessary. Though the final structure should not be the same, it should represent more than one type of inheritance if class diagram is drawn.
8. The private member’s are made public to all the classes in inheritance.
Explanation: The private member’s scope can’t be changed and those can never be accessed in other classes. Only the class containing private member’s can access its own members.
9. If hierarchical inheritance requires to inherit more than one class to single class, which syntax is correct? (A, B, C are class names)
a) hierarchical class A: public B, public C
b) multiple class A: public B, public C
c) many class A: public B, public C
d) class A: public B, public C
Explanation: The syntax is as same as declaration of other classes. There is no specific keyword defined for using hybrid inheritance in programming. Only thing is to specify the class name separated by commas.
10. What is the maximum number of classes allowed in hybrid inheritance?
d) As many as required
Explanation: The classes in any type of inheritance can inherit as many classes as required. The only condition that may arise is memory management. The classes can inherit most of the features from more than one class.
11. What is the minimum number of classes to be there in a program implementing hybrid inheritance?
d) No limit
Explanation: The answer is no limit. There is no condition defined for limit of classes that has to be used in hybrid. Though you must have at least 4 classes so that one set of multiple or hierarchical inheritance is there and one more class to use single level inheritance.
12. If object of lowest level class is created (last derived class) ________________ of its parent class constructors are called.
c) Only parent and parent
d) Base and Derived
Explanation: When derived class object is created, all of its successor parent classes constructors are called. Constructor of all the connected classes is not created. Since the parent members have to be initialised, but other derived classes are not needed.
13. If hybrid inheritance is used, it mostly shows _______________ feature of OOP.
d) Code readability
Explanation: The code is reusable in most of the classes and the data becomes more linked to other classes. Other features are also exhibited, but the code reusability is used the most. Code readability becomes relatively less. Flexibility increases but it depends on how the hybrid inheritance is used.
14. The sequence of destructors being called while using hybrid inheritance is ____________
a) Reverse of constructors being called
b) Reverse of classes being made
c) Reverse of objects being created
d) Reverse of code calling objects
Explanation: The destructors are always called in reverse order of constructors being called always. The type of inheritance doesn’t matter. The only important concept is the sequence of classes being inherited.
15. Overloading operators are possible only by using hybrid inheritance.
Explanation: The overloading concept is not related to the types of inheritance being used. Overloading operators can be done without using inheritance. You don’t even have to use more than one class for operator overloading.
Sanfoundry Global Education & Learning Series – Object Oriented Programming (OOPs).
To practice all areas of Object Oriented Programming (OOPs) using C++, here is complete set of 1000+ Multiple Choice Questions and Answers.