Definition
An interface refers to an abstract object (which can be another entity) that provides itself to the outside world. It is used to separate external communication methods from internal operations, this allows it to be modified internally without affecting the interaction between other external entities, just as multi-Abstraction provided by object-oriented programming.
Abstract classes are often used to represent the abstract concepts obtained from the analysis and design of problem domains. They are the abstraction of a series of seemingly different but essentially identical specific concepts.
Same
Both interfaces and abstract classes are source self-structured structures, both of which contain abstract methods and cannot generate instances.
Different
- Abstract classes are the abstraction of objects, and interfaces are a type of behavior specification. For example, a man is a man and a man eats dinner. Here, the man is a subclass, the man is an abstract class, and the meal is an interface.
- A class can inherit only one abstract class and can implement multiple interfaces.
- Abstract classes can contain non-Abstract METHODS, constructors, and interfaces.
- The member variables of the abstract class can be modified by different modifiers, and the default interface is the static constant static final. This feature is derived from the second point. Similarly, the interface method is static abstract by default.