1. The interface must be abstract. abstract can be written or not, and the meaning is identical.
2. Interfaces can only be modified with public or default access restriction modifiers.
3. The variables in the interface are implicitly public static final. Even if the keyword is not explicitly modified, it is automatically added during compilation.
4. The methods in the interface must be public and abstract. They must not be static or final.
5. The interface reference can point to the objects of all classes that indirectly or directly implement the interface.
6. The mutual assignment between Interface references must satisfy certain rules. The mutual assignment between Interface references is similar to that between class references, as listed below:
Sub-interface references can be directly assigned to parent interface references;
Forced type conversion is required when a parent interface is referenced by a subinterface;
Other interface references that do not inherit link types also require forced type conversion.
7. The assignment rules between class reference and interface reference are as follows:
Class references to interface references do not require forced type conversion. During compilation, check whether the class directly or indirectly implements this interface. If this interface is compiled, it can be run;
The interface reference is assigned to the class reference for forced type conversion, and the target class must implement this interface to pass compilation. If the object does not match during runtime, an exception is reported.
8. The specific meanings of interfaces and abstract classes are quite different. Abstract classes pay more attention to what they are and their nature, while interfaces pay more attention to what functions they have and what roles they can play.
9. The differences between class and interface references pointing to objects are listed below:
Inheritance only allows a superclass reference to point to an object of the same class. For example, a meat reference can only point to a meat object;
Interface reference can point to any class object, even if there is no relationship between objects, as long as the class of these objects implements this interface.