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 6 of 6

Thread: Inheritance

  1. #1
    Junior Member vasanthjayaraman's Avatar
    Join Date
    Jul 2013
    Location
    Chennai
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Inheritance

    Hi Guys:-
    Why Multiple Inheritance not Supported in Java?

    I Need Clear Definition Please Anyone Help me...........................


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Inheritance

    This sub-Forum is titled "What's Wrong With My Code?", meaning there should be questions involving code. Your question is about Java theory, so the sub-forum "Java Theory And Questions" seems more suitable.

  3. #3
    Senior Member PhHein's Avatar
    Join Date
    Mar 2013
    Location
    Germany
    Posts
    609
    My Mood
    Sleepy
    Thanks
    10
    Thanked 93 Times in 86 Posts

    Default Re: Inheritance


  4. #4
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Inheritance

    Thread moved from Whats wrong with my code

  5. #5
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,676
    Thanks
    25
    Thanked 329 Times in 305 Posts

    Default Re: Inheritance

    The technical answer would be due to inheritance meaning an "is-a" relationship (you can find a bunch of information regarding this online).

    But the practical answer would be simply because multiple inheritance is one of those things which has an extremely rare need, but is extremely common to be abused (refer to some of the multiple inheritance articles for C++). Basically, the idea is that multiple inheritance encourages developers to inherit classes for the purpose of reusing code, instead of the actual purpose of inheritance, which is relationship mapping. Generally speaking, if you find your class needs to inherit more than one object, you should probably consider refactoring.
    NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

    When asking for help, please follow these guidelines to receive better and more prompt help:
    1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
    2. Give full details of errors and provide us with as much information about the situation as possible.
    3. Give us an example of what the output should look like when done correctly.

    Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/

  6. #6
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,895
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: Inheritance

    Multiple inheritance has to solve the Diamond Problem.

    The safest and easiest solution to this problem while keeping most of the benefits of complete multiple inheritance is to ensure every "class" multiply inherited from has no data members, and no defined methods (a.k.a. contains only abstract methods). This is called an "interface". So what you end up with is the ability for single inheritance and multiple interfaces, a reduced form of multiple inheritance.

    Java's design reasoning is that this pattern solves the vast majority of problems while avoiding the Diamond Problem, and calls it a day. So yes, you are crippled in what you can do, but it's probably for your own good (this is the reason for quite a few features of the Java language).

Similar Threads

  1. Help with inheritance
    By jean28 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: November 8th, 2012, 12:07 AM
  2. hi need help with inheritance
    By fredsilvester93 in forum Java Theory & Questions
    Replies: 2
    Last Post: July 19th, 2012, 04:01 PM
  3. Inheritance
    By lewzax in forum Object Oriented Programming
    Replies: 4
    Last Post: July 8th, 2011, 01:51 PM
  4. inheritance help
    By justin3492 in forum Object Oriented Programming
    Replies: 3
    Last Post: September 30th, 2010, 07:45 PM
  5. inheritance
    By b109 in forum Java Theory & Questions
    Replies: 3
    Last Post: May 30th, 2010, 09:23 PM