250+ TOP MCQs on Multilevel Inheritance and Answers

Object Oriented Programming (OOPs) Multiple Choice Questions & Answers (MCQs) on “Multilevel Inheritance”.

1. Which among the following best defines multilevel inheritance?
a) A class derived from another derived class
b) Classes being derived from other derived classes
c) Continuing single level inheritance
d) Class which have more than one parent
Answer: b
Clarification: Only if the class is being derived from other derived class, it can be called as multilevel inheritance. If a class is derived from another class, it is single level inheritance. There must be more than one level of inheritance.

2. If there are 5 classes, E is derived from D, D from C, C from B and B from A. Which class constructor will be called first if the object of E or D is created?
a) A
b) B
c) C
d) A and B
Answer: a
Clarification: A is parent of all other classes indirectly. Since A is parent of B and B is parent of C and so on till E. Class A constructor will be called first always.

3. If there are 3 classes. Class C is derived from class B and B is derived from A, Which class destructor will be called at last if object of C is destroyed.
a) A
b) B
c) C
d) All together
Answer: a
Clarification: The destructors are called in the reverse order of the constructors being called. Hence in multilevel inheritance, the constructors are created from parent to child, which leads to destruction from child to parent. Hence class A destructor will be called at last.

4. Which Class is having highest degree of abstraction in multilevel inheritance of 5 levels?
a) Class at 1st level
b) Class 2nd last level
c) Class at 5th level
d) All with same abstraction
Answer: a
Clarification: The class with highest degree of abstraction will be the class at the 1st level. You can look at a simple example like, a CAR is more abstract than SPORTS CAR class. The level of abstraction decrease with each level as more details comes out.

5. If all the classes use private inheritance in multilevel inheritance then ______________
a) It will not be called multilevel inheritance
b) Each class can access only non-private members of its parent
c) Each subsequent class can access all members of previous level parent classes
d) None of the members will be available to any other class
Answer: b
Clarification: The classes will be able to access only the non-private members of its parent class. The classes are using private inheritance, hence all the members of the parent class become private in the derived class. In turn those won’t be allowed for further inheritance or direct access outside the class.

6. Multilevel inheritance allows _________________ in the program.
a) Only 7 levels of inheritance
b) At least 7 levels of inheritance
c) At most 16 levels of inheritance
d) As many levels of inheritance as required
Answer: d
Clarification: The multilevel inheritance allows any number of levels of inheritance. This is the maximum flexibility feature to make the members available to all the new classes and to add their own functionalities. The code reusability is used too.

7. What is the minimum number of levels for a implementing multilevel inheritance?
a) 1
b) 2
c) 3
d) 4
Answer: c
Clarification: There must be at least 3 levels of inheritance. Otherwise if less, it will be single level inheritance or would have got no inheritance implemented. There must be a derived class from which another class is derived.

8. In multilevel inheritance one class inherits _______________
a) Only one class
b) More than one class
c) At least one class
d) As many classes as required
Answer: a
Clarification: The classes inherit only from one class. This continues as each class inherits only one class. There should not be any class that inherits from two or more classes or which have more than one subclass.

9. All the classes must have all the members declared private to implement multilevel inheritance.
a) True
b) False
Answer: b
Clarification: There is no mandatory rule to make the members private for multilevel inheritance. Moreover, if all the classes have only the private members then there won’t be any member to get inherited. Hence the working will be of no use.

10. Can abstract classes be used in multilevel inheritance?
a) Yes, always
b) Yes, only one abstract class
c) No, abstract class doesn’t have constructors
d) No, never
Answer: a
Clarification: The abstract classes can always be used in multilevel inheritance. The only condition that may arise is that all the undefined functions must be defined in subclasses. There must not be any undefined function.

11. How many abstract classes can be used in multilevel inheritance?
a) Only 1
b) Only 2
c) At least one less than number of levels
d) Can’t be used
Answer: c
Clarification: At least one class must implement all the undefined functions. Hence there must be at least one class which is not abstract. That is at least one less than number of levels.

12. If all the classes used parameterized constructors and no default constructor then ___________
a) The object of lower level classes can’t be created
b) Object of lower level classes must call parent class constructors explicitly
c) Object of lower level classes must define all the default constructors
d) Only object of first class can be created, which is first parent
Answer: b
Clarification: Each class constructor must be called before creating the object of any subclass. Hence it will be mandatory to call the constructors of parent classes explicitly with parameters. This will make all the previous class member be initialized and then the class in use will be able to create the object.

13. In multilevel inheritance, which is the most significant feature of OOP used?
a) Code readability
b) Flexibility
c) Code reusability
d) Code efficiency
Answer: c
Clarification: The classes using multilevel inheritance will use the code in all the subsequent subclasses if available. Hence the most significant feature among the options given is code reusability. This feature is generally intended to use the data values and reuse the redundant functions.

14. Does following code show multiple inheritance?

class A
	int a;
class B
	int b;
class C:public A, public B
	int c;
class D:public C
	int d;

a) Yes, class C and class D
b) Yes, All together it’s multilevel
c) No, 4 classes are used
d) No, multiple inheritance is used with class A, B and C
Answer: d
Clarification: Since multiple inheritance is used to derive class C and then class D is derived from class C. This is not multilevel inheritance. The classes should derive from single class. This is actually hybrid inheritance.

15. Is it compulsory for all the classes in multilevel inheritance to have constructors defined explicitly if only last derived class object is created?
a) Yes, always
b) Yes, to initialize the members
c) No, it not necessary
d) No, Constructor must not be defined
Answer: c
Clarification: It’s not mandatory to define the constructors explicitly. Default constructor will always be provided by the compiler itself if none another constructor is defined in those classes. If explicit default constructor is defined it will be used.

Leave a Reply

Your email address will not be published. Required fields are marked *