Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Why does Interfaces extend java.lang.Object

807569Sep 22 2006 — edited Sep 23 2006
Hi,
I notice that all the interfaces extends java.lang.Object. As per myunderstanding from some books on Java, interfaces cannot extend classes.

But all interfaces do inherit methods from Object class. Why is this so?
(i am able to call Object class methods on an Interface reference).

This behavior is not intended for interfaces. If an Interface is extending from java.lang.object,. it means that Object is the superclass of all interfaces and this means we should be able to call new on the interfaces.

Why would we need to allow interfaces to extend only from java.lang.Object and not any other class? The answer for this can be
that if interfaces dont inherit methods from Object, then there would not be a default way to validate if two interface objects are equal, and also the interfaces would not get that Object's behavior that all classes get by default.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 21 2006
Added on Sep 22 2006
14 comments
1,392 views