Why Java does not support multiple inheritance?

Kalpanagosavi

Kalpanagosavi

@kalpanagosavi-NNhb7x Oct 27, 2024
please tell me the reasons why java does not support multiple inheritance?

Replies

Welcome, guest

Join CrazyEngineers to reply, ask questions, and participate in conversations.

CrazyEngineers powered by Jatra Community Platform

  • Anoop Kumar

    Anoop Kumar

    @anoop-kumar-GDGRCn Jul 4, 2015

    Try answering this and you will find understand yourself -
    If an child will have two father.
    Father1 with color white and father2 with color black.
    What will be the color of child?
  • Ankita Katdare

    Ankita Katdare

    @abrakadabra Jul 6, 2015

    Kalpanagosavi
    please tell me the reasons why java does not support multiple inheritance?
    Because JAVA is a "simple", "object oriented", "distributed", "secure", "multi-threaded", "high performance", "dynamic" language.
  • WARDHAMAN BEDMUTHA

    WARDHAMAN BEDMUTHA

    @wardhaman-HBFrS6 Jul 6, 2015

    Lets consider a Class Test -

    Class Test {

    public int add ()
    {
    return 1 ;
    }
    }


    Now Class Test1 and Class Test2 extends class Test


    Class Test1 extends Test

    {
    public int add() --Method add is overridden here
    {
    return 2;
    }

    }


    Class Test2 extends Test {


    public int add() --Method add is overridden here
    {
    return 3;
    }

    }

    Now consider a Class Test3 extends Test1, Test2

    Now which version of method add will be implemented in Class Test3 ?
    Will it be with return 3 or with return 2?

    This will lead to confusion,right ?

    So Java does not support multiple inheritance, means creators of Java does not support multiple inheritance.
  • Kalpanagosavi

    Kalpanagosavi

    @kalpanagosavi-NNhb7x Jul 10, 2015

    Thank u!!!
  • msec123

    msec123

    @msec123-0yCTXA Jul 12, 2015

    Java absolutely support multiple inheritence in terms of Interface.We can extend one class only to avoid ambiguity problem.In interface we have to define the functions.So we don't get any ambiguity.In c++ it is big problem with multiple inheritence but in JAVA this thing is improved by introducing Interfaces
  • chanks

    chanks

    @chanks-RBcmf9 Jul 18, 2015

    tell me difference between Machine code and Native code