wood burning stoves 2.0*
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
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
Author

why multiple inheritance is directly prohibited in java?

Soumya Ranjan Padhi
Greenhorn

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

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

Joined: Apr 04, 2012
Posts: 924
    
    1

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
Bartender

Joined: Oct 02, 2003
Posts: 11154
    
  16

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: 131
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 implemtation..so same problem not possible.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: why multiple inheritance is directly prohibited in java?