Answer the question
In order to leave comments, you need to log in
Interfaces default to inherit from Object class in Java?
Hello!
I just started learning Java 8 and I had this question: Is the
interface inherited from the Object class by default or not?
If yes, for what purpose? You cannot create an instance of a class from an interface.
If not, then why is it said that everything is an object except primitive types?
Thanks in advance!
Answer the question
In order to leave comments, you need to log in
With this type of reference, you can call Object methods on the object, such as toString or hashCode.
So technically yes, it is inherited.
At a minimum, this allows such references to be stored in collections.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question