Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why multiple inheritance is not allowed in Java

 
Venkat Sadasivam
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For long time I had a question �why Sun introduced Interface concept
instead of C++ style of multiple inheritance?�. I did googling but
many articles and forums talks about difference between abstract class
and Interface not why Interface concept required in Java. After
extensive search and analysis I came to know the reason behind the
Interface concept in Java.

Here is my finding and conclusion.
http://venkatsadasivam.wordpress.com/2008/08/02/why-multiple-inheritance-is-not-allowed-in-java/

If you have difference of opinion, do post your comments.
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could have made it easy on yourself by looking up "multiple inheritance" in Wikipedia. It would have pointed you right away at the diamond problem.
 
Venkat Sadasivam
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are right. wikipedia mentioned as "Java do not allow multiple inheritance; this results in no ambiguity".

I didn't find during my google search. Moreover it doesn't support any programmatic examples.
 
pradeep singh
Ranch Hand
Posts: 339
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Java does not support multiple inheritence because of its various disadvantages.One amoung them is Suppose a class Animal having public eat() method.2 other classes say Lion and Tiger extends this Animal class.Now there is also a third class Tigon which extends both Lion and Tiger.Now could you tell me if i call eat method in Tigon class then which one either from Lion or Tiger class?

I think it helps you better in understanding this .............
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic