Multiple Inheritance in java

前端 未结 8 1398
無奈伤痛
無奈伤痛 2020-11-27 21:27

Java is not allowing inheritance from multiple classes (still it allows inheritance from multiple interfaces.), I know it is very much inline with classic diamond problem. B

相关标签:
8条回答
  • 2020-11-27 21:57

    Java designers decided that. Multiple inheritance can be simulated by the use of interfaces.

    0 讨论(0)
  • 2020-11-27 21:59

    The diamond problem arises when multiple parent classes define their own implementations of something and the child class of these two has to deal with the ambiguity of which implementation to use. So what if all classes in Java derive from Object, that's a single parent class. "Single parent, multiple derived classes" is not the same as "Multiple parents, single derived class"

    0 讨论(0)
提交回复
热议问题