aspose file tools*
The moose likes Java in General and the fly likes isn't interface support  inheritance Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "isn Watch "isn New topic
Author

isn't interface support inheritance

sam liya
Ranch Hand

Joined: Nov 25, 2008
Posts: 1204


i found this question from paper.
but the answer is c and d.
that means interface doesn't support inheritance.
is it true?
Sebastian Janisch
Ranch Hand

Joined: Feb 23, 2009
Posts: 1183
How can the answer be C and D ? That doesn't make any sense ...


JDBCSupport - An easy to use, light-weight JDBC framework -
sam liya
Ranch Hand

Joined: Nov 25, 2008
Posts: 1204
i am also sayn that
answer should not be c and d.
Sebastian Janisch
Ranch Hand

Joined: Feb 23, 2009
Posts: 1183
I don't get you. You say that the answer is C and D. Look at the answers, they can't both be correct.

As for the inheritance, it is possible to achieve inheritance using interfaces through composition which is even preferred to the 'old fashioned' inheritance due to it's high flexibility.
Anwar Hussain
Ranch Hand

Joined: Jul 24, 2009
Posts: 35
I suppose Answer is A and B.
Interface just defines the protocol for concrete sub classes.
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

Are the terms "Inheritance Relationship" and "Realization Relationship" used anywhere outside of UML?

In the context of UML, my understanding is this:
Inheritance Relationship: Behavior inheritance
Realization Relationship: Contract fulfillment

In Java when we talk about inheritance we typically think of anything with an 'IS-A' relationship, but in UML it is different. The Inheritance Relationship uses a solid line (open triangle) arrow to show where Behavior is coming from, and the Realization Relationship uses a dashed line (open triangle) arrow to show where contract comes from.

The Java equivalent to the Inheritance Relationship is extends and the Java equivalent for Realization Relationship is implements, though the boundaries can be a bit fuzzy (Abstract classes can define new contracts as well, and if a class implements an interface is has an IS-A relationship with the interface.

So based on that:
(a) Abstract class support to the inheritance relationship but not realization relationship.
This is true, Abstract classes use extends which is indicative of Inheritance.

(b) Interface supports to the realization relationship but not inheritance relationship.
This is true, interfaces use implements which is indicative of Realization

(c) Both Abstract class and Interface are supporting inheritance relationship.
If (b) is true then this must be false

(d) All above statements are correct.
If any of the above are false then this must be false


Steve
sam liya
Ranch Hand

Joined: Nov 25, 2008
Posts: 1204
anyway is that mean does java interface support inheritance ?
Anwar Hussain
Ranch Hand

Joined: Jul 24, 2009
Posts: 35
No
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14274
    
  21

aruna sameera wrote:i found this question from paper.

What paper? Please quote your sources - that's required on JavaRanch when you copy a question from a mock exam, book or other source.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: isn't interface support inheritance