Each object has a type (and value). * There are many types: primitive types (e.g. int ), class types (e.g. string ), enumerations, arrays (and maybe I forget about some).
The term βinterfaceβ refers to a particular type of class type: it is a class that does not have member objects (safe constants) and only public methods, all of which are abstract. **
So: an interface is a special class, which, in turn, is a special type of type. Thus, interfaces are types. In your example, both Animal and Lion are types, and one of them can be converted to the other.
*) It is clear that the type says: "What is the structure of this," and the meaning says "what is the content." Type 5 is int , and its value ... well, 5.
**) This allows you to inherit from several interfaces, while in Java it is impossible to inherit from several common classes.
source share