The fact about Java is that it does not support the multiple inheritance.
But I have a question that the base class of all java classes is Object.
Now we have tw
class B
inherits from class A
which in turn inherits from Object
. Object
is at top of the inheritance hierarchy. This is multi level inheritance , not multiple inheritance.
Object class is base class of all other classes.Here when you inherit class B from class A then class B can not be inherit from Object class.
public class B extends class A
{
}
And here, base class of class A is Object class.
So in short, if we not inherit any class then its base class would be object class.
You can also refer this:
http://docs.oracle.com/javase/tutorial/java/concepts/inheritance.html
What you describe is not multiple inheritance; B inherits from a single super class, A and A inherits from a single super class, Object. B gains the properties and methods of both A and Object, but this is via a single 'chain'of inheritance.
Multiple inheritance is where a class inherits directly from more than one, unrelated class. This is not possible in Java.
A, and B inherits Object so A inherits Object when inherits B.
Think of inheritance as an "is a" relation.
In Java we can have
A dog is a mammal is an animal
but not
A dog is a mamal and a four legged animal
mammal and four leggeld animal are at the same level but mammal and animal are at different levels.
The reason we can have the first but not the second is if we know that mammals talk in a certain way, animals talk in a certain way and four legged animals talk in a certain way we can work out the way dogs talk unambiguously in the first case but not the second.
A class always extends only one class. That is the Object class or the class defined with the extends keyword. That class in turn can extend also only one class until eventual the Object class is reached.