File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes multiple inheritance vs multiple implementation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "multiple inheritance vs multiple implementation" Watch "multiple inheritance vs multiple implementation" New topic
Author

multiple inheritance vs multiple implementation

Padma Kanaka
Greenhorn

Joined: Jan 22, 2004
Posts: 5
Hi all,
1)I know java does not support multiple inheritance.
Can anybody give me a precise answer for why multiple
implementation is better than multiple inheritance!

2)Accessing which variable is faster? Can you specify the order,
local variable, instance variable, static variable, index of an
array.
Thanks,
Padma
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Multiple inheritance can be done - it's there in other languages. The inventors of Java looked at those other languages and decided it brings along too much complexity for the developer and the compiler and JVM implementors. They started Java with the goal of being small and simple, not the world's ultimate OO langauge, so compromises like that make sense and we just live with them. I'm fine with the choice - single inheritance is hard enough to get right!

Any variable access on the same object or class will be fast enough to not worry about - local, static, member. I would absolutely go for human understanding in my code before any optimization of that kinda thing. Indexed arrays are probably very fast, too. The access algorithm is dead simple.

Other collections and such do have some speed differences in various operations. My Collections Crib Sheet has some hints on how to select which collection to use. BTW: I'm aware the crib sheet is missing some perfectly fine collection classes. Send me any suggestions for improvements via mail from the site. Thanks!!
[ September 25, 2004: Message edited by: Stan James ]

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Mike Gershman
Ranch Hand

Joined: Mar 13, 2004
Posts: 1272
The real killer in multiple inheritance is when methods with the same name and signature are inherited from two different parents. The rules for deciding which one to call on a child object are complicated.

Then there is diamond inheritance, where Method() in class A is inherited by two child classes B and BB, then class C inherits from B and BB. Does it matter which side Method() comes down from? Then suppose that Method() is overridden in class B but not in class BB. How is super.Method() interpreted?

The advantage of multiple implementation is that the obligation to provide a method can be inherited many times but the implementation will only be provided or inherited once. No ambiguities.


Mike Gershman
SCJP 1.4, SCWCD in process
avaneesh reddy
Greenhorn

Joined: Aug 10, 2006
Posts: 2
The advantage of multiple implementation is that the obligation to provide a method can be inherited many times but the implementation will only be provided or inherited once. No ambiguities.

can you make this point more clear...


avaneesh
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: multiple inheritance vs multiple implementation
 
Similar Threads
Use of Interface
multiple inheritence in core java
MULTIPLE IMPLEMENTATION INHERITANCE
Multiple Inheritance in Java
MultipleImplementation Inheritance using Inner Class