• Post Reply 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
  • Devaka Cooray
  • Tim Cooke
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
Saloon Keepers:
  • Piet Souris
Bartenders:

Multiple Inheritance

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why java does not support multiple Inheritance through classes?
 
Ranch Hand
Posts: 255
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am guessing that there was a problem in C++ with it. but you can get the desired results with
class myclass extends dog implements sheep, cat {
}
------------------
I wish there was a button on my monitor to turn up the intellegince.
Theres a button called 'brightness' but it doesn't work
 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Multiple inheritance is useful when a new class wants to combine multiple contracts and inherit some, or all, of the implementation of those contracts. but when there is more than one superclass, problem arise when a superclass's behaviour is inherited in two ways. Assume, for a moment, the following type tree:
X estends W
Y extends W
Z extends X
Z extends Y
This is commonly called diamond inheritance, and there is nothing worng with it. many legitimate designs show this structure. The problems exist in the inheritance of implementation, where W's implementation stores some state. If class W had, for example, a public field named gogging, and if you had a reference to an object of type Z called zref, what zref.goggin refer to ? It might refer to X's copy of goggin, or it might refer to Y's copy, or X and Y might share a single copy of goggin because Z really only a W once even thought it is both and a Y.
Resolving such issues is non-trivial and complicates the design and use of class hierarchies. To avoid such issues, the Java programming language uses the single inheritance model of OOP.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic