Is the possible deadly diamond of death in Java ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Is the possible deadly diamond of death in Java ?

Using, Class, Interface or enum.. for interface can multiple extends. so is there deadly diamond problem possible or not? example : A,B, C and D are the four interfaces then parent-child relationship is A / \ B C \ / D

9th Jul 2018, 3:53 AM
Sandeep Kushwaha
Sandeep Kushwaha - avatar
4 Answers
+ 5
Hello, Sandeep Kushwaha ! What do you mean? Please write in more detail, and people will be able to help you.
9th Jul 2018, 5:04 AM
Alexander Sokolov
Alexander Sokolov - avatar
+ 5
Please read the link I provided. It already answered to your question before you edited it. " ...interfaces specify only what the class is doing, not how it is doing it... " subclasses merely implement interfaces, not extend their behaviour. The diamond problem exists when a subclass inherits from multiple superclasses which have conflicting definitions for what an inherited method should do. By implementing interfaces, you define how the class performs the method.
10th Jul 2018, 10:43 PM
Hatsy Rei
Hatsy Rei - avatar
+ 4
Multiple inheritance is not allowed in Java, so there's no diamond problem there. You may point out that implementing multiple interfaces are allowed - https://stackoverflow.com/questions/2515477/why-is-there-no-multiple-inheritance-in-java-but-implementing-multiple-interfac
9th Jul 2018, 7:32 AM
Hatsy Rei
Hatsy Rei - avatar
0
is D faced "Deadly diamond of death".? in question
10th Jul 2018, 4:44 PM
Sandeep Kushwaha
Sandeep Kushwaha - avatar