In which type of inheritance, a class can inherit from more than one class?
202320232023
In which type of inheritance, a class can inherit from more than one class?
- A.
Single Inheritance
- B.
Multiple Inheritance
- C.
Multilevel Inheritance
- D.
Hierarchical Inheritance
Attempted by 5 students.
Show answer & explanation
Correct answer: B
Inheritance in object-oriented programming is classified by how many parent classes a single derived class draws members from directly. When a class lists more than one base class in its own declaration and inherits methods and attributes from every one of them at once, that mechanism is called Multiple Inheritance.
This question asks which inheritance type lets a class inherit from more than one class — that is exactly Multiple Inheritance. Languages such as Python and C++ allow a class to name several base classes together; Java avoids multiple inheritance of classes (though it allows it for interfaces) because of the "Diamond Problem", where the compiler cannot tell which parent's version of a shared member to use.
Single Inheritance: a class derives from exactly one parent class, so it never combines members from two or more parents.
Multilevel Inheritance: forms a chain (grandparent to parent to child) — every class in that chain still has only one direct parent, not several at the same level.
Hierarchical Inheritance: one parent class has several child classes branching from it — the reverse direction of a class drawing from more than one parent.