wood burning stoves 2.0*
The moose likes Java in General and the fly likes multiple inheritance Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "multiple inheritance" Watch "multiple inheritance" New topic
Author

multiple inheritance

Revati Pathak
Greenhorn

Joined: Feb 19, 2001
Posts: 26
why doesn't java allow multiple inheritance?
what are the practical dificulties in allowing
a class to extend more than 1 class.
After all , it allows multiple inheritance thro' implementation of interfaces.
Sean MacLean
author
Ranch Hand

Joined: Nov 07, 2000
Posts: 621
I can't speak for the creators of Java, but since the develoment of Simula 67 there have been two schools of thought concerning object orientation and multiple inheritence. Basically, Simula 67 (often called the first oo language) promotes the concept that multiple inheritence goes against 'pure' oo principles. Languages like C++ see things differently. I'm sure lots of other folks can come up with other reasons (excuses? ).
Sean
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

One of the major problems with multiple inheritance is if both parent classes have the same method. If that method is called on the child class, which method actually gets invoked?

Multiple inheritance is a very confusing concept, and doesn't have that may valid uses... the few valid uses that multiple inheritance does have can be accomplished in Java through interfaces. ( And the problem listed above isn't a problem with interfaces, since they only contain only method signatures and not actual method implementations... )

-Nate


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Karthik Guru
Ranch Hand

Joined: Mar 06, 2001
Posts: 1209
Originally posted by Nathan Pruett:
One of the major problems with multiple inheritance is if both parent classes have the same method. If that method is called on the child class, which method actually gets invoked?

Multiple inheritance is a very confusing concept, and doesn't have that may valid uses... the few valid uses that multiple inheritance does have can be accomplished in Java through interfaces. ( And the problem listed above isn't a problem with interfaces, since they only contain only method signatures and not actual method implementations... )

-Nate

hi Nate,
just an observation,
I noticed that C# also does'nt've multiple inheritance BUT they allow you to "optionally, explicity" :-),
define 2 different implementations for the methods with same signature coming from 2 interfaces if you happen to implement both of them. You just need to prefix the interface name in front of the methods!
I was just wondering they c'd've very well suported multiple implementation inheritance like C++ when they have given this provision.
karthik.

 
 
subject: multiple inheritance
 
Similar Threads
doubt on mutiple inheritance
Object Class is father of all??
Object class by default break to rule of multipul inheritance
super class, class
multiple inheritance