• 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
  • 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 Inheritance in Java

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
We all know that JAVA supports OOPS.One of the main concepts in OOPS is Inheritance. Inheritance can be in many forms.One of them is Multiple Inheritance.So JAVA should also support this type of Inheritance.How...? We all also know that JAVA doesn't support it.We can extend a class with only one class.Ofcourse we can implement more than one interface.
My question is what is the secret(is this word OK?) behind this?
I think you have understood my problem.
Anybody...Please clarify my doubt.
Regards
Sujan.
 
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
consider the following:
You have 3 classes: ClassA, ClassB and ClassC that derives
ClassA and ClassB. Imagine that both ClassA and ClassB do have
a method called 'doSth()'. Now imagine that you create a new
instance of classC and invoke the derived method 'doSth()'. What
method will be performed?
The 'doSth()' method of classA or classB?
This is a problem that will never occur in Java classes because
we do have single inheritance.

------------------
Marco Barenkamp
____________________________________________
L M I N T E R N E T S E R V I C E S AG
Senior Trainer & Architect,
BEA Certified Enterprise Developer
Sun Certified Programmer for the Java2 Platform
Sun Certified Web Component Developer for the Java2 Platform
Sun Certified Developer for the Java 2 Platform
Sun Certified Enterprise Architect for the Java 2 Platform Enterprise Edition (PI)
 
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are many different ways of implementing inheritance, not all of them necessarily desirable in the same language. Java follows after Smalltalk, which implemented only Single inheritance plus a form of "interface" inheritance. (In fact, Smalltalk's a bit complicated to explain in this way since it's an untyped language -- in effect you can send a message to any object and never get a compile time error -- because these are all trapped at runtime. However, the design principles are the same for Java and Smalltalk).
This is different from C++, Java's other "parent" as it were, which implemented multiple inheritance, but had no "interface" inheritance. CLOS had a third type of inheritance, called "delegation". In fact, there is no problem that you can't solve using any of the four languages. The designs may differ, but the outcome will be the same, even though it may take a tiny bit more work to accomplish it in one vs. the other.
Kyle
------------------
Kyle Brown,
Author of Enterprise Java (tm) Programming with IBM Websphere
See my homepage at http://members.aol.com/kgb1001001 for other WebSphere information.
 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This has nothing to do with J2EE so I am sending this to... hmmmm... OO, Patterns, etc.
 
permaculture is giving a gift to your future self. After reading this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic