File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

isn't interface support inheritance

 
sam liya
Ranch Hand
Posts: 1240
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
Posts: 1183
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can the answer be C and D ? That doesn't make any sense ...
 
sam liya
Ranch Hand
Posts: 1240
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am also sayn that
answer should not be c and d.
 
Sebastian Janisch
Ranch Hand
Posts: 1183
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 35
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suppose Answer is A and B.
Interface just defines the protocol for concrete sub classes.
 
Steve Luke
Bartender
Pie
Posts: 4181
21
IntelliJ IDE Java Python
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
sam liya
Ranch Hand
Posts: 1240
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
anyway is that mean does java interface support inheritance ?
 
Anwar Hussain
Ranch Hand
Posts: 35
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic