Because multi-inheritance is not allowed in Java, You can implement multiple interfaces to implement the functions of multiple classes.
Java interfaces and Java Abstract classes represent abstract types, which are the specific manifestations of the abstraction layer we need to propose. To improve the Reuse Rate of programs, increase the maintainability and scalability of programs, the OOP object-oriented programming must be interface-oriented and abstract-oriented, correctly Use interfaces and abstract classes as the top layers of your structural hierarchy.
There are too many similarities between Java interfaces and Java Abstract classes, and there are too many special points. What exactly is the best place for Java interfaces and Java Abstract classes? By comparing them, you can find out.
1. The biggest difference between Java interfaces and Java Abstract classes is that Java Abstract classes can provide partial implementation of some methods, but Java interfaces cannot. This is probably the only advantage of Java Abstract classes, however, this advantage is very useful. If a new concrete method is added to an abstract class, all its subclasses will get this new method at once, and the Java interface cannot do this, if you add a new method to a Java interface, all classes that implement this interface cannot be compiled successfully, because you must make every class implement this method again, this is obviously a disadvantage of the Java interface.
2. The implementation of an abstract class can only be given by the subclass of this abstract class. That is to say, this implementation is in the hierarchy defined by the abstract class. Due to the single inheritance of the Java language, therefore, the efficiency of an abstract class as a type definition tool is greatly reduced. At this point, the advantages of the Java interface come out. Any class that implements the method specified by a Java interface can have the type of this interface, A class can implement any number of Java interfaces, so this class has multiple types.
3. From the 2nd point, it is not difficult to see that the Java interface is an ideal tool for defining the hybrid type. The mixed class indicates that a class has not only a primary type but also other secondary behaviors.