aspose file tools*
The moose likes Beginning Java and the fly likes Multiple Interface Inheritance / Interface Inheritance Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Multiple Interface Inheritance / Interface Inheritance" Watch "Multiple Interface Inheritance / Interface Inheritance" New topic
Author

Multiple Interface Inheritance / Interface Inheritance

kri shan
Ranch Hand

Joined: Apr 08, 2004
Posts: 1373
Inteface A

Interface B extends A ---> Is it Interface Inheritance ?

Class C implements B --> Is it Multiple Interface Inheritance ?

Java does not support Interface Inheritace.

fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11312
    
  16

an interface is a contract - nothing else. When you have

Interface A {}

you are saying "here are the rules for what it means to implement the 'A' interface.

When you say "implements A", you are saying "This class/abstract class will implement everything required by the A interface"

so,

interface B extends A

is just saying "here are the rules for implementing the B interface, which by the way, must also implement the A interface."

and "Class C implements B" is just saying "I promise that the C class will implement everything required by the B interface (which just so happens to also require implementation of the A interface".

it's not really inheritance at all.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Jarred Olson
Ranch Hand

Joined: Jul 31, 2009
Posts: 37
fred rosenberger wrote:

interface B implements A



Just a nitpick, but interfaces extend other interfaces, not implement.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11312
    
  16

oops...
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14149
    
  18

Multiple inheritance means: a class that extends two classes.

But if you make a "chain": B extends A, and C extends B - then that is not multiple inheritance.

Java doesn't have multiple inheritance because it causes some hard problems like the diamond problem and because it's not an essential feature. A large part of Java was designed to look like C++, but with the hard parts left out. This is an example of a C++ feature that was left out of Java.

See http://en.wikipedia.org/wiki/Multiple_inheritance


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Multiple Interface Inheritance / Interface Inheritance