Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

multiple inheritence in core java

 
Ranch Hand
Posts: 129
1
Oracle Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
can anyone clearly explain me about multiple inheritence.., syntactically it is allowed but conceptually it's not.., so please send in u'r replies..,
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Hi, welcome to the ranch

The next time you want to post, please use real words.

(I'm moving this thread to a more appropriate forum)
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Multiple inheritence is the ability to extend two unrelated classes. This feature is *not* supported by Java.

Henry
 
Ranch Hand
Posts: 385
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Java supports only Multilevel inheritance not multiple inheritance.

Multilevel -A class extend only one class directly but its super class can extend another class and so on.In java every class is a child class of class called Object.

Multiple-A class can extend more than one class directly.
Multilevel:

class A
class B extends A
class C extends B

Multiple:

class A
class B
class C extends A,B
 
karthik Suryanarayanan
Ranch Hand
Posts: 129
1
Oracle Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
thank you very much ranchers..,
 
Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator

karthik rsn wrote:can anyone clearly explain me about multiple inheritence.., syntactically it is allowed but conceptually it's not.., so please send in u'r replies..,



Both a class and an interface represents a type. The difference is that a class can carry implementation but an interface cannot.

Now the Java inheritance model supports multiple inheritance of type but only single inheritance of implementation. So Java allows a class to inherit one class at the most but an unlimited number of interfaces. An interface can inherit an unlimited number of interfaces.

In OO design the inheritance of type is considered most important and here Java imposes no restrictions. Java supports multiple inheritance of type.

When it comes to inheritance of implementation Java imposes a restriction. At the most one implementation can be inherited. The reason for this limitation, given in the Java Programming Language by Gosling and others, is problems associated with so called diamond inheritance.

In practice multiple inheritance of implementation, although not supported by Java, can be simulated. This is done by splitting up the class to be inherited into one interface that's inherited and one implementation class that's delegated. The only drawback is that it requires more writing.

So in summary, Java supports multiple inheritance of type, the most important form of inheritance in OO design. Java supports single inheritance of implementation only, but multiple inheritance of implementation can easily be simulated.
 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
is there a technical answer as to why multiple inheritence is removed fron java.....the diamond problem is still possible through interfaces...so why didn't they remove multiple inheritence through interfaces?
 
Henry Wong
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator

Mohnish Khiani wrote:is there a technical answer as to why multiple inheritence is removed fron java.....the diamond problem is still possible through interfaces...so why didn't they remove multiple inheritence through interfaces?



As already answered in the other topic that you bumped -- having the ability to form a diamond doesn't mean that it is a "diamond problem".

And please don't bump multiple topics -- one should be enough.

Henry

 
It's weird that we cook bacon and bake cookies. Eat this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
    Bookmark Topic Watch Topic
  • New Topic