We say that java follows a single inheritance model i.e. a Java class can extend only one class at max. and then say that every java class is inherited from Object class.
Suppose there are two classes A and B. Both A and B extend from Object. Now suppose A extends B. Doesn't it imply that A has multiple inheritence (A is inheriting from both B and Class Object)?
A Java class can only directly inherit from one class. In this case,
A
doesn't directly inherit fromObject
, only fromA
.Are you solely asking from the perspective of terminology, or is there some behaviour you're interested in?
In Java, each class can directly extend only from one parent class. So, either B extends from Object and A extends from B, xor both A and B extend from Object.
You are supposing that both is true at the same time - this is not possible in Java.
If B extends from Object, and A extends from B, then yes, A does inherit from Object, but there is still a single parent to each and every class:
In other words, Java doesn't support multiple inheritance.
You can have an inheritance chain, this is not multiple inheritance. You cannot have a class that inherits from more than one class at a time.
Forbidden by the language: