Object Oriented Programming using C++ Questions and Answers – Hybrid Inheritance

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
View Answer

Answer: a
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
View Answer

Answer: b
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
b) Multilevel
c) Hybrid
d) Multiple
View Answer

Answer: b
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.
advertisement
advertisement

4. Diamond problem includes ____________________ hybrid inheritance.
a) Hierarchical and Multiple
b) Hierarchical and Hierarchical
c) Multiple and Multilevel
d) Single, Hierarchical and Multiple
View Answer

Answer:a
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.
a) Hierarchical
b) Multiple
c) Multilevel
d) Hierarchical and Multiple
View Answer

Answer: a
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
View Answer

Answer: d
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?
a) Multiple
b) Hierarchical
c) Multilevel
d) None
View Answer

Answer: d
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.
advertisement

8. The private member’s are made public to all the classes in inheritance.
a) True
b) False
View Answer

Answer: b
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
View Answer

Answer: d
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.
advertisement

10. What is the maximum number of classes allowed in hybrid inheritance?
a) 7
b) 127
c) 255
d) As many as required
View Answer

Answer: d
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?
a) 2
b) 3
c) 4
d) No limit
View Answer

Answer: d
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.
a) Few
b) All
c) Only parent and parent
d) Base and Derived
View Answer

Answer: c
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.
a) Flexibility
b) Reusability
c) Efficiency
d) Code readability
View Answer

Answer: b
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
View Answer

Answer: a
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.
a) True
b) False
View Answer

Answer: b
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.

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.