Reputation: 95
Is to possible that a superclass that already inherited from Object Class and at same time a subclass that inherited from superclass can also inherited from object class directly ?
Upvotes: 1
Views: 42
Reputation: 36304
Java has multi-level inheritance.
Say class X extends class Y
and then class Y extends class Z
, then class X
access class Object via class Y
(which inturn accessesclass Object via class Z
)
Upvotes: 1
Reputation: 178461
No, because that will require Multiple Inheritence - which does not exist in java.
The work-around for multiple inheritence in java is usage of interfaces, and an interface does not extend object.
So, in other words - a class can extend only one other class (which in its turn extends Object), but it cannot extend another class.
Upvotes: 1