File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes why multiple inheritance is directly prohibited in java? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "why multiple inheritance is directly prohibited in java?" Watch "why multiple inheritance is directly prohibited in java?" New topic

why multiple inheritance is directly prohibited in java?

Soumya Ranjan Padhi

Joined: Jun 27, 2012
Posts: 10
Hi every one....
Please answer this query......
Krishna Chhabra

Joined: May 15, 2007
Posts: 9
Why multiple inheritance prohibited
gurpeet singh
Ranch Hand

Joined: Apr 04, 2012
Posts: 924

multiple inheritance is prohibited because of a very simple reason. just imagine you have 2 super classes and one sub class inherting from above 2 superclasses. now suppose that both the superclass defines method with same signature i.e. same name and same number and type of arguments. now just think about it, which method out of 2 will subclass inherit. this is also called diamond of death.
fred rosenberger
lowercase baba

Joined: Oct 02, 2003
Posts: 11927

If you want to know the real answer, you'd have to ask the people who originally defined the spec. Everything else is only guesses.

Yes, multiple inheritance can cause problems. The common belief is that the language developers decided it caused more problems than it solved.

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Satyaprakash Joshii
Ranch Hand

Joined: Jun 18, 2012
Posts: 194
in java a class cant extend 2 classes : because if same method same implementation is there in both which one will be inherited?but in java we allow a class to implement 2 interfaces? now can the same problem occur with interfaces? NO because interfaces dont have same problem not possible.

I agree. Here's the link:
subject: why multiple inheritance is directly prohibited in java?
It's not a secret anymore!