Module: | Core Architecture, Basics & Control Flow
Q18: Consider the following statements regarding inheritance fundamentals in Java:
1. Java classes officially support Single, Multilevel, and Hierarchical inheritance architectures natively.
2. Multiple inheritance via classes is strictly prohibited in Java to prevent ambiguity known as the Diamond Problem.
3. Every single user-defined class in Java implicitly inherits from the java.lang.Object class, making it the supreme root of the inheritance hierarchy.
Which of the above statements is/are correct?
2. Multiple inheritance via classes is strictly prohibited in Java to prevent ambiguity known as the Diamond Problem.
3. Every single user-defined class in Java implicitly inherits from the java.lang.Object class, making it the supreme root of the inheritance hierarchy.
Which of the above statements is/are correct?
✅ Correct Answer: D
🎯 Quick Answer:
The correct combination is 1, 2, and 3.Structural Breakdown: Java utilizes the extends keyword for class inheritance.
The supported structural types are Single (A to B), Multilevel (A to B to C), and Hierarchical (A to B, A to C). Historical/Related Context: In C++, multiple inheritance (inheriting from multiple parent classes) was permitted, but it frequently caused the Diamond Problem where the compiler could not determine which parent's method to execute if both possessed identical signatures.
Java's architects intentionally banned multiple inheritance with classes to ensure language simplicity.
Causal Reasoning: Every class inherently extending java.lang.Object guarantees that standard utility methods like equals(), hashCode(), and toString() are universally available across the entire Java ecosystem, establishing a unified object interaction baseline.