Why does Interfaces extend java.lang.Object
807569Sep 22 2006 — edited Sep 23 2006Hi,
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.