Test Series - oops

Test Number 45/78

Q: 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
Solution: 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.
Q: 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
Solution: There must be combination of at least 2 types of inheritance. The inheritance should be of different type.
Q: 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
Solution: 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.
Q: Diamond problem includes ____________________ hybrid inheritance.
A. Hierarchical and Multiple
B. Hierarchical and Hierarchical
C. Multiple and Multilevel
D. Single, Hierarchical and Multiple
Solution: 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.
Q: If __________________ inheritance is done continuously, it is similar to tree structure.
A. Hierarchical
B. Multiple
C. Multilevel
D. Hierarchical and Multiple
Solution: 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.
Q: 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
Solution: 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.
Q: Which type of inheritance must be used so that the resultant is hybrid?
A. Multiple
B. Hierarchical
C. Multilevel
D. None
Solution: 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.
Q: 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
Solution: 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.
Q: What is the maximum number of classes allowed in hybrid inheritance?
A. 7
B. 127
C. 255
D. As many as required
Solution: 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.
Q: 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
Solution: 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.

You Have Score    /10