Test Series - oops

Test Number 44/78

Q: Each class can inherit the base class ________________
A. Independently using any inheritance
B. Independently with private inheritance only
C. With same type of inheritance
D. With each class using different inheritance only
Solution: The classes can inherit the base class using any type of inheritance. There is no mandatory condition to use same private,public or protected inheritance only.
Q: How many classes must be there to implement hierarchical inheritance?
A. Exactly 3
B. At least 3
C. At most 3
D. At least 1
Solution: At least 3 classes must be there. Two derived classes and one base class. This lets us implement two classes that have common characteristics from base class.
Q: Base class _______________
A. Can be made abstract
B. Can’t be made abstract
C. Must be abstract
D. If made abstract, compile time error
Solution: The base class may or may not be declared abstract. It depends on the need of program. If it is made abstract, it can contain undefined functions too. In turn, those functions will have to be implemented by each of the derived classes.
Q: Which access specifiers should be used so that all the derived classes restrict further inheritance of base class members?
A. Private
B. Public
C. Protected
D. Any inheritance type can be used
Solution: All the derived classes must use private inheritance. This will make the members of base class private in derived classes. Hence none of the members of base class will be available for further inheritance.
Q: How many classes can be derived from the base class using hierarchical inheritance?
A. As many as required
B. Only 7
C. Only 3
D. Up to 127
Solution: The number of classes that can be derived from a base class doesn’t have any restriction and hence will be able to derive as many classes as required. This feature gives more flexibility and code reusability.
Q: Which among the following is true?
A. Hierarchical inheritance is subset of multiple inheritances
B. Hierarchical inheritance is strongest inheritance type
C. Hierarchical inheritance uses only 2 classes for implementation
D. Hierarchical inheritance allows inheritance of common features to more than one class
Solution: Hierarchical inheritance is used to make all the inherited classes have some common features obtained from a single base class. This allows all the classes to maintain a group or to be classified under one class.
Q: Hierarchical inheritance can be a subset of _________________
A. Hybrid inheritance
B. Multiple inheritance
C. Single level inheritance
D. Multilevel inheritance
Solution: When we use hybrid inheritance, it can contain any type of inheritance or combination or more than two types. Hence it may contain Hierarchical inheritance too, hence it can be subset of hybrid inheritance.
Q: Which type of inheritance is most suitable for inheriting Same syllabus into different colleges with different streams?
A. Multiple
B. Single
C. Hierarchical
D. Multilevel
Solution: When hierarchical inheritance is used, the common syllabus can be adopted into different college classes where the same syllabus is applicable. For changing the syllabus only the details of base class will have to changed.
Q: Which class constructor is called first when an object of derived class is created?
A. Base class constructor
B. Derived class constructor
C. Firstly created derived class constructor
D. Last created derived class constructor
Solution: The base class must be initialised first hence the constructor of base class is called first. This makes everything ready for the new object being created.
Q: All the derived classes can access only a few members of base class that other derived classes can’t access at same time, in hierarchical inheritance.
A. True
B. False
C. 1
D. 0
Solution: The derived classes have full access to all the non private member’s of base class. Every derived class have equal access, none of the class can have special access to specific members of base class in general cases.

You Have Score    /10