Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Why Java Doesn’t Support Multiple Inheritance

  1. #1
    Junior Member
    Join Date
    Jul 2018
    Location
    Mumbai, India
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Why Java Doesn’t Support Multiple Inheritance

    The main point to be discussed over here is Java does not support multiple inheritance or Java does support? There are lots of people who are still under confusion that it supports but actually it does not support using interface in Java. Even the father of Java has once admitted the fact.

  2. #2
    Junior Member
    Join Date
    Aug 2018
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Why Java Doesn’t Support Multiple Inheritance

    Hello,

    Quick answer is NO, Java dose not support multiple inheritance.

    Here is why it dose not support:

    Lets consider the following class hierarchy:

    public class Car {
         public void accelerate() {}
    }
     
    public class SportsCar extends Car {
         public void accelerate() {} //<----- overridden inherited method from Car class  
    }
     
    public class SUV extends Car {
         public void accelerate() {} //<----- overridden inherited method from Car class
    }
     
    public class Mercedes extends SportsCar, SUV {
         public void accelerate() {} //<----- Mercedes class inherit the accelerate method but the question is WHICH ONE???
    }

    That is why Java do not allow multiple inheritance. This is also called the "Deadly Diamond of Death"

    I hope this helps.
    Regards
    Alin

Similar Threads

  1. Confusion in Multiple inheritance in Java
    By Ganeprog in forum What's Wrong With My Code?
    Replies: 4
    Last Post: January 9th, 2014, 08:35 AM
  2. why java does not support multiple inheritance?
    By venkatsairam in forum Object Oriented Programming
    Replies: 3
    Last Post: January 18th, 2012, 04:25 PM
  3. Replies: 1
    Last Post: September 30th, 2010, 02:36 PM