Hi,
why java does not support multiple Inheritance ?
Multiple Inheritance in Java
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted Oct 21, 2011, 9:45 AM EDT
It was felt that the problems of multiple inheritance (the diamond problem, virtual base classes etc.) outweighed the usefulness of the feature.
However, classes in Java and C# can both implement multiple interfaces instead.
Satyapriya NayakRank #47 · 31.5K reputationPosted Oct 21, 2011, 10:07 AM EDT
Multiple inheritance means derive class from multiple classes but java can't extend multiple classes.Java supports multiple inheritance through the
use of interface.We can extend one class only to avoid ambiguity problem.In interface we have to define the functions.So we don't get any ambiguity.
Thanks
VulpesRank #55 · 29.2K reputationPosted Oct 21, 2011, 10:19 AM EDT
In C#, you can get around this with 'explicit interface implementation' where you actually specify the interface name when implementing the member and can only call it using a reference of that interface type. By these means, you can have a different implementation for each interface.
Java does not have this feature and so you can only have a single implementation for all interface members which share the same name or signature.