multiple inheritance in java
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   vijay_raghavan
Posted On:   Tuesday, November 23, 2004 09:35 PM

can u please explain why java is not supporting multiple inheritance

Re: multiple inheritance in java

Posted By:   Anonymous  
Posted On:   Friday, December 3, 2004 10:28 AM

A shorter answer: Multiple inheritance has a very complex semantics. If you know the "diamond problem", you know what I'm talking about; if not, you must believe me that it creates very complex questions about what inheritance should mean at all ... (B.Meyer would maybe oppose this view).


Regards


Harald M.

Re: multiple inheritance in java

Posted By:   Sherbir_S  
Posted On:   Tuesday, November 23, 2004 11:26 PM



Hi Vijay,

The Java design team strove to make Java:


Simple, object oriented, and familiar.
Robust and secure , Architecture neutral and portable.
High performance Interpreted, threaded, and dynamic

The reasons for omitting multiple inheritance from the Java
language mostly stem from the "simple, object oriented, and
familiar" goal. As a simple language, Java's creators
wanted a language that most developers could grasp without
extensive training. To that end, they worked to make the
language as similar to C++ as possible (familiar) without
carrying over C++'s unnecessary complexity (simple).

In the designers' opinion, multiple inheritance causes more
problems and confusion than it solves. So they cut multiple
inheritance from the language (just as they cut operator
overloading). The designers' extensive C++ experience
taught them that multiple inheritance just wasn't worth the
headache.

Instead, Java's designers chose to allow multiple interface
inheritance through the use of interfaces, an idea borrowed
from Objective C's protocols. Multiple interface
inheritance allows an object to inherit many different
method signatures with the caveat that the inheriting
object must implement those inherited methods.

Multiple interface inheritance still allows an object to
inherit methods and to behave polymorphically on those
methods.

In particular, the singly rooted hierarchy (with Object as
the ultimate ancestor of all classes) and Java interfaces
solves most problems that are commonly solved using
multiple inheritance in C++.

Hope this helps.

Cheers !!

Sherbir

About | Sitemap | Contact