aspose file tools*
The moose likes Blatant Advertising and the fly likes Why multiple inheritance is not allowed in Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Other » Blatant Advertising
Bookmark "Why multiple inheritance is not allowed in Java" Watch "Why multiple inheritance is not allowed in Java" New topic
Author

Why multiple inheritance is not allowed in Java

Venkat Sadasivam
Ranch Hand

Joined: May 10, 2008
Posts: 139
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.


“Any fool can write code that a computer can understand. Good programmers write code that humans can understand. ”<br>
-Martin Fowler
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39547
    
  27
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.


Ping & DNS - updated with new look and Ping home screen widget
Venkat Sadasivam
Ranch Hand

Joined: May 10, 2008
Posts: 139
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

Joined: Oct 23, 2007
Posts: 339
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 .............


SCJP 5.0(75%), SCWCD 5.0(88%)
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Why multiple inheritance is not allowed in Java
 
Similar Threads
Can interfaces have same effect as multiple inheritance
Magic behind the serializable interface
Java Concepts :confused:
Multiple inheritance
Print PDF file from Java API