+ 1
Why java doesn't have multiple inheritance through classes?
3 Respuestas
+ 2
Consider a example of multiple inheritance , where A has 2 child class let's say B and C. And D is child class of B and C. Now if D wants to inherit any property of A then there are 2 paths either through B or through C. Compiler here gets confused which path to pick. The case of multiple inheritance leads to ambiguity. This is why java doesn't support multiple inheritance. However, it does support multi-level inheritance.
+ 3
As Chetali Shah Java is built in that manner, and prevents diamond inheritance.
https://www.google.com/amp/s/www.freecodecamp.org/news/multiple-inheritance-in-c-and-the-diamond-problem-7c12a9ddbbec/amp/
C++ allows you do it, at your own risk. Typically I avoid using diamond inheritance.
+ 3
A program cant make a decision unless it's been told how and that's what the problem is with the diamond pattern.. your asking the program to solve possible ambiguity between 2 methods without knowing why even the human brain cant do that unless theres a reason.
Its similar to me asking you if I use your phone should I call john or Kevin? Without you knowing why?