We all know, in java, all classes by default inherits Object class.
Yes. But I suspect that you don't understand what that really means.
What it means is that if a class is not declare (via an explicit extend
) to inherit from some class, then it implicitly inherits from Object
.
class A {} // implicitly inherits Object
class B extends A {} // explicitly inherits A
To say this in other words:
A
has Object
as its only direct superclass
B
has A
as its only direct superclass.
B
has Object
as an indirect superclass.
This is single inheritance. Multiple inheritance would be if B
had A
and Object
as direct superclasses.