Why only single inheritance is allowed in Java, but is it possible to implement multiple interfaces?
1, the interface can inherit multiple interfaces. Why can't I implement multiple inheritance of classes? The main is to prevent multiple classes have the same method name, but the method body is not the same, subclasses are more difficult to choose. So Java and C # do not support multiple inheritance of classes
2, one of the benefits of allowing multiple interfaces is that when implementing multiple interfaces, if two interfaces have the same method, then the implementation is possible once. Because the interface has no method body, the interface can implement multiple inheritance.
How do you indirectly implement multiple inheritance for a class?
1. Multiple inheritance can be implemented by inheriting several interfaces .
2, A, B, C.
Class-To-Interface inheritance interface with abstract class abstraction factory