I am not asking this -> Why is there no multiple inheritance in Java, but implementing multiple interfaces is allowed?
In Java, multiple inheritance isn't allowed, but, after Java 8, implemented interfaces can have default methods, just like abstract classes. Within this context, it multiple inheritance should also be allowed.
Things are not so simple.
If a class implements multiple interfaces that defines default methods with the same signature the compiler will force you to override this method for the class.
I think that we cannot apply the same logic for multiple inheritances because multiples issues could occur which the main are :
- overriding the method of an inherited class could introduce side effects and change the overall behavior of the inherited class if the class relies on this method internally.
- how to inherit multiple fields ? And even if the language allowed it you would have exactly the same issue as this previously quoted : side effect in the behavior of the inherited class : a
int foofield defined in a
Bclass that you want to subclass doesn't have the same meaning and intention.