The emergence of interfaces avoids the limitations of single inheritance.
Little known secret:
Interface to interface relationship? ?
100% is not an implementation , because both are abstract
Therefore, there is an inheritance relationship between interfaces and interfaces , and interfaces can be multi-inherited! ! !
Because the difference between multiple inheritance is in the method body , but the method in the interface has no method body.
What is the difference between an interface and an abstract class? ? (emphasis)
Differences between interfaces and abstract classes:
Same point:
They are all drawn upwards. not specific enough
difference:
1. Abstract classes need to be inherited, and only single inheritance.
Interfaces need to be implemented, and there can be multiple implementations.
2. Abstract methods and non-abstract methods can be defined in abstract classes, and non-abstract methods can be used directly after subclass inheritance.
Only abstract methods can be defined in an interface, which must be implemented by subclasses.
3. Inheritance of abstract classes is a relationship that defines the basic common content of the system.
The implementation of the interface is like a relationship. (Like, similar) Additional functions in the definition system.
In different problem areas, there are different ways of analysis.