Pages Navigation Menu

Coding is much easier than you think

Why Multiple Inheritance is Not Supported in Java ?

 

The short answer is: because the language designers decided not to.

In an white paper titled “Java: an Overview” by James Gosling in February 1995 gives an idea on why multiple inheritance is not supported in Java.
 

JAVA omits many rarely used, poorly understood, confusing features of C++ that in our experience bring more grief than benefit. This primarily consists of operator overloading (although it does have method overloading), multiple inheritance, and extensive automatic coercions.

Who better than Dr. James Gosling is qualified to make a comment on this. This paragraph gives us an overview and he touches this topic of not supporting multiple-inheritance.
 
 Is Interface a way to multiple inheritance in Java ?
 
Some say, java supports multiple inheritance using interface. No. There is no support for multiple inheritance in java.This story of supporting multiple inheritance using interface is what we developers cooked up.

Interface gives flexibility than concrete classes and we have option to implement multiple interface using single class. This is by agreement we are adhering to two blueprints to create a class.

This is trying to get closer to multiple inheritance. What we do is implement multiple interface, here we are not extending (inheriting) anything. The implementing class is the one that is going to add the properties and behavior. It is not getting the implementation free from the parent classes. I would simply say, there is no support for multiple inheritance in java.
 
 
Why Java does not support multiple inheritance?

 
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.

 

About Lourde


Am currently working as a Spring Developer in a reputed IT Organisations. Trying to become a Professional Expert Blogger...8)

    Splitting PDF File Using Java iText API
    All tutorial

    One Comment

    1. Raj Asteroid

      coz it fought with existing class :p

    SimpleCodeStuffs located at 511/67 Huynh Van Banh , Ho Chi Minh, VN . Reviewed by 56 customers rated: 4 / 5