This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Multiple inheritance and Multiple Interfaces Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Multiple inheritance and Multiple Interfaces" Watch "Multiple inheritance and Multiple Interfaces" New topic
Author

Multiple inheritance and Multiple Interfaces

aakash bhatt
Ranch Hand

Joined: Jan 09, 2003
Posts: 182
Hi all,
When in Java we can multiple interface why not multiple inheritance.
What disadvantages has taken off by removing multiple inheritance and adding
of multiple interfaces.
Regards,
aakash
Greg Charles
Bartender

Joined: Oct 01, 2001
Posts: 2550
    
  10

One big problem with mulitple inheritance is what to do when both base classes implement a particular method differently. If the subclass doesn't override this method, what code should be called? This situation often arises when both base classes themselves extend from a common ancestor. In this case, a class hierarchy diagram would show a diamond pattern of classes.
This conflict doesn't exist for interfaces, because they don't provide implementations. It is perfectly acceptable for a class to implement two interfaces that define the same method. However, if the interfaces defined methods with identical signatures, but differing return types, there would still be a conflict.
[ February 20, 2003: Message edited by: Greg Charles ]
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Multiple inheritance and Multiple Interfaces
 
Similar Threads
Difference Between Abstract Class and Interface
multiple inheritance in java
Abstract & Interface
Multiple Inheritance - Reusability
innerclass