Multiple Inheritance Ambiguity with Interface

前端 未结 6 2200
轮回少年
轮回少年 2020-12-24 12:48

We all know about the diamond problem regarding multiple inheritance -

   A
  / \\
 B   C
  \\ / 
   D

This problem describe an ambiguous

6条回答
  •  梦毁少年i
    2020-12-24 13:38

    Java doesn't support multiple inheritance, so the diamond problem doesn't arise. If B & C are interfaces, then there is no implementation in the interfaces. Even if B & C override the method in interface A (cannot be a class), the methods will have same signature. There is no ambiguity regarding which implementation to use, because there is no implementation.

提交回复
热议问题