I am pretty new to OOP. We all know that Java does not support multiple inheritance; however, all Java classes inherit from Object
and can also inherit from another class. Can we consider this as multiple inheritance? How does Java handle such a thing?

- 671
- 1
- 8
- 19

- 1,147
- 4
- 19
- 46
-
possible duplicate of [Interview Puzzle - Multiple Inheritance in Java?](http://stackoverflow.com/questions/24378375/interview-puzzle-multiple-inheritance-in-java) – Raedwald Jan 27 '15 at 08:08
5 Answers
It's not multiple inheritance it's multi level inheritance. Classes can extend one other class, which can extend one other class, ..., which ultimately extends Object:
A --> B --> C --> Object
Multiple inheritance would be
A ----> B
\
\--> C
This means that when a method or a field is used inside A, it's looked up in A, then in B, then in C, then in Object.
With multiple inheritance, it would have to be looked up in A, then in B and C, and there could be a conflict because the same method or field could exist in both superclasses.

- 1,147
- 4
- 19
- 46

- 678,734
- 91
- 1,224
- 1,255
-
if we have a class that doesn't inherit from any class this class by default inherit from class object.But if we have class A that inherit from class B class A inherits from B and Object because B inherit from it .Is what what you mean?? – Ibrahim Amer Jul 27 '13 at 11:44
-
No. Class A inherits from B, which inherits from Object. A class has always one and only one direct superclass (except Object, which doesn't have any). – JB Nizet Jul 27 '13 at 11:46
That is not multiple inheritance ....That is multi level inheritance in java
Excepting Object, which has no superclass, every class has one and only one direct superclass (single inheritance). In the absence of any other explicit superclass, every class is implicitly a subclass of Object.

- 120,458
- 37
- 198
- 307
Your class that extends that other class, but it extends Object, too, so you're still in one line of inheritance, not multiple inheritance.
It calls as a multi-level inheritance. not multiple inheritance.

- 7,512
- 7
- 39
- 72
Its still multi level inheritance. If u would use multiple inheritance in java - use intefrace for these purposes.
Because:
Java support only multiple interface inheritance, and java does not support multiple inheritance

- 1,892
- 3
- 26
- 40
what you explain is multilevel inheritance that allowed in java.
but multiple inheritance not allowed in java.

- 5,336
- 5
- 33
- 54