Difficulty: Easy
Correct Answer: Correct
Explanation:
Introduction / Context: Multilevel inheritance means a class derives from a class that itself derives from another class, forming a chain such as A → B → C → D. This is a foundational capability in classical OOP languages like C++ and is conceptually supported in Java via single inheritance of classes (interfaces are separate). The question tests whether such layered hierarchies are permitted.
Given Data / Assumptions:
Concept / Approach: In multilevel inheritance, every class in the chain inherits the accessible members of its parent. Constructors and destructors (or finalizers) are invoked in well-defined orders. Method overriding, virtual dispatch (C++) or dynamic dispatch (Java), and polymorphism apply transitively.
Step-by-Step Solution:
Define base A with some interface/behavior.Define B : A to inherit and extend A.Define C : B, further extending behavior.Define D : C, completing the chain. This is valid and common.Verification / Alternative check: Many standard libraries organize types in inheritance chains (e.g., Java’s java.io hierarchy). Unit tests that instantiate D can call methods from A, B, and C according to access rules.
Why Other Options Are Wrong:
Common Pitfalls: Confusing multilevel inheritance (legal) with multiple inheritance of classes (restricted in Java). Poorly designed deep chains can harm maintainability, but that is a design smell, not a prohibition.
Final Answer: Correct
Discussion & Comments