From the Java fact that all class in Java have a parent class as Object
. But the same Java says that it doesn\'t support multiple inheritance. But what this code me
From the Java fact that all class in Java have a parent class as Object
Actually no, that's not true. Object
is only the default parent class. If you explicitly specify a parent, as in your example (A extends B
), then the class you're defining no longer has Object
as an immediate parent.
However, the fact that Object
is the default means that it's impossible to create a class (except for Object
itself) without a superclass. Since every class must have a superclass, every class has to have Object
as an ancestor at some level.