13. Does java support multiple inheritance?

Does java support multiple inheritance?

Java does not support multiple inheritance through class but we can achive that through interface.
In Java, a class can implement multiple inteface and an interface can extends multiple interface.

 

Diamond Problems


However, we need to carefully with multiple inheritances because it can cause diamond problems. For example, we have class A implement 2 interface is interface B and interface C. Both two interface have method with  the same name. So, there is an ambiguous to know whether method from interface B or interface C will be called.

Leave a Reply

Your email address will not be published. Required fields are marked *