Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

why multiple inheritance is directly prohibited in java?

 
Soumya Ranjan Padhi
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi every one....
Please answer this query......
 
Krishna Chhabra
Greenhorn
Posts: 9
 
gurpeet singh
Ranch Hand
Posts: 924
1
Fedora Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 12097
30
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Satyaprakash Joshii
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic