Results 1 to 10 of 10

Thread: why multiple inheritance is not supported by java?

  1. #1

    Thumbs down why multiple inheritance is not supported by java?

    why multiple inheritance is not supported by java?


  2. #2
    Junior Member
    Join Date
    Jan 2008
    Answers
    5

    Re: why multiple inheritance is not supported by java?

    java was designed in that way it doesnt support syntactically but conceptually it is possible with interfaces


  3. #3
    Junior Member
    Join Date
    Mar 2008
    Answers
    2

    Re: why multiple inheritance is not supported by java?

    that is because if a child is inheriting from two classes ,and if both the parent classes have the same method (same signature and same return type),the compiler will be confused as the method in the child overrides which parent


  4. #4
    Junior Member
    Join Date
    Mar 2008
    Answers
    1

    Re: why multiple inheritance is not supported by java?

    in c++ also the multiple inheritance is there but due to ur saying reason we use the virtual function in c++.In java also we can use the virtual function so whats the deffect to use the multiple inheritance


  5. #5
    Junior Member
    Join Date
    Aug 2009
    Answers
    2

    Re: why multiple inheritance is not supported by java?

    actually we can use it,but indirectly witn the help of interfaces..
    but my qs. is why not directly..?


  6. #6
    Junior Member
    Join Date
    Aug 2009
    Answers
    2

    Re: why multiple inheritance is not supported by java?

    what are actually interfaces?


  7. #7
    Expert Member
    Join Date
    May 2009
    Answers
    1,374

    Re: why multiple inheritance is not supported by java?

    Quote Originally Posted by shreya suri View Post
    what are actually interfaces?
    Hi ,

    Interface is the collection of methods with empty implementations and constants variables ( variables with static and final declarations ).

    All the methods in an interface are "public and abstract" by default. Since interfaces are abstract in nature so they can not be directly instantiated.

    To define the methods of an interface the keyword "implements" is used.

    Eg:


    interface check
    {
    public void message();
    }
    public class Interface {
    public static void main(String[] args) {
    try {
    check t = new check() {
    public void message() {
    System.out.println("Method defined in the interface");
    }
    };
    t.message();
    } catch (Exception ex) {
    System.out.println("" + ex.getMessage());
    }
    }
    }

    If any query let me know....


    Thanks,
    Riju.


  8. #8
    Junior Member
    Join Date
    Aug 2009
    Answers
    1

    Re: why multiple inheritance is not supported by java?

    i dont think just because making the java simple and robust we don't have mulitple inhertiance and if it so why do they provided Interface concept for us....
    and one thing more that we can have same method name with same return type via METHOD OVERRIDING...


  9. #9
    Junior Member
    Join Date
    Sep 2009
    Answers
    2

    Thumbs down Re: why multiple inheritance is not supported by java?

    Quote Originally Posted by shreya suri View Post
    what are actually interfaces?
    interfaces are there in java to support polymorphism not for multiple inheritance java not at all support multiple inheritance


  10. #10
    Junior Member
    Join Date
    Oct 2009
    Answers
    3

    Re: why multiple inheritance is not supported by java?

    hi fnds

    in java we have diamond property . i.m if the two parent class have the same method signature and different implementations the the jvm confused which parent class method it invoke....... this naming convention is called diamond property in java.

    thats y in java it doesn't support multiple inheritance directly, but it suppots indirect multiple inheritance throw interfaces bcz if the two in interfaces having same name even thow that method implementation existeds only once in the child class .....so there is no confusion to jvm which method implementation it invoke.........


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact