If there are no constructors in the interfaces, then is there a class class of the super interface class?

I read that interfaces have no constructors, which means that he will not call super () his superclass. I also read that every class in Java is a subclassObject

What about an interface, is it a subclass of Object? Why?

+5
source share
5 answers

No no. An interface cannot be created to create an object; it is not a class.

+5
source

No interface is a subclass of the Object class, because an interface cannot extend a class, implicit or explicit.

, , - , , , .

+1

( ). .

, . , , , .

interface Interface{
     abstract String fun();
 }

Interface interfc=new Interface() {
    @Override
    public String fun() {
        return super.toString();
    }
};

Type type=interfc.getClass();

. java language. super, .

An anonymous class cannot have an explicitly declared constructor.

, .

+1

"can-do", "is-a", , " __er" " __able". , ( ), , , , - " " ". - :" ", . , - :" ? " " ", " ", , ," " " ". " " " ".

Java. , . , , , ; -: ", - ", , . , "". , , , , , . , "", .

0

An interface cannot have a constructor. Because the interface supports multiple inheritance. This means that if a class inherits two interfaces, then there will be ambiguity due to the constructor chain, the constructor of which will be called from the constructor of the class.

0
source

All Articles