Is an interface a class?

后端 未结 6 1232
醉梦人生
醉梦人生 2020-12-15 17:18

Is an interface a special kind of class or can you say that an interface isn\'t a class at all?

6条回答
  •  庸人自扰
    2020-12-15 18:20

    The concept of interfaces comes from Abstract Classes, where as abstract classes contains prototypes of method (or abstract methods) and can have few of its methods defined also, while interfaces contains only the prototypes(or signature) of method or abstract methods, whose definition is to be provided by the implementing class. so from the above statement it is clear that interfaces are like 100 percent abstract classes where - none of its method is defined. mentioning it again interfaces are like 100 percent abstract classes but not the classes.

    "Interfaces are contracts for what a class can do"

    A reason for introducing interface is, we can extend only single class but interface brought a new thing implement in java so we can implement thousands of interface.So we can not say that it is a class.

    you can get more about this Here!

提交回复
热议问题