Forums Register Login

isn't interface support inheritance

+Pie Number of slices to send: Send


i found this question from paper.
but the answer is c and d.
that means interface doesn't support inheritance.
is it true?
+Pie Number of slices to send: Send
How can the answer be C and D ? That doesn't make any sense ...
+Pie Number of slices to send: Send
i am also sayn that
answer should not be c and d.
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
I suppose Answer is A and B.
Interface just defines the protocol for concrete sub classes.
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
anyway is that mean does java interface support inheritance ?
+Pie Number of slices to send: Send
No
+Pie Number of slices to send: Send
 

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.
Are you here to take over the surface world? Because this tiny ad will stop you!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1401 times.
Similar Threads
(navie) Question on HashMap instanceof Collection
realization relationship
Inheritance or Class and its instance
Does Java Support Multiple Inheritance
Realization relationship -- dashed arrow or solid line?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 00:52:58.