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 two classes : Class A and Class B. B is inherited from A then the Base class of B would be the Object and A , so here, the multiple inheritance took place.
Anyone will please help me to clear my doubt?
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 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.
A, and B inherits Object so A inherits Object when inherits B.
The concept of
Multiple Inheritance
means, that you can have a class A, B and C where A is derived from B and C like this:This is not possible in Java.
What you describe is a straightforwar inheritance with a direct line of descendenats.
You don't really need Multiple Inmheritance though, because with
Interfaces
you can basically achieve the same in a much cleaner way.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.
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
Think of inheritance as an "is a" relation.
In Java we can have
but not
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.