Multiple inheritance is not allowed in java but any class we create has a parent class "Object". So when we extend any other class, then thats a multiple inheritance. Is n't it?? its bit confusing.Any body can explain this please?
Asked
Active
Viewed 84 times
2 Answers
1
Multiple inheritance means one class has multiple direct parent classes it inherits from. As long one class has only one direct parent class it inherits from, this is not multiple inheritance.
Multiple inheritance:
C ---> B
|
|--> A
Single inheritance:
C ---> B ---> A

Harmlezz
- 7,972
- 27
- 35
-
Thanks for help.But m nt clear yet.Isn't Object class direct parent of what ever class we create?? IF so,how come this is single inheritance?? – Eagle Mar 10 '14 at 14:42
-
Single inheritance means your class inherits from exactly **one class** and possibly implements many interfaces. Multiple inheritance means your class inherits **directly** from two or more classes. The problem with multiple inheritance is, if more than one class your class inherits from define the same method (e.E. B.m and A.m), which one to choose when compiling C.m, given C does not override _m_. Did my comment help? – Harmlezz Mar 10 '14 at 14:46
-
First scenario (Object-->A) and (Object-->B) Where A and B are 2 user defined classes. Now B-->A. What I am thinking is now Object--->A | | B------- :forgive my pictorial representation. But What m trying to say is now both Object and B class are super class A.Is n't it multiple inheritance?? :( – Eagle Mar 10 '14 at 15:05
0
Nope, any class that doesn't extend explicitly extends Object, so let's assume that you have 2 classes, A and B , and B extends A, the heirachy will look as follows:
Object>A>B
So A directly inherits Object, and B directly inherits A and indirectly Object :)

HishamGarout
- 1,743
- 3
- 11
- 12