This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

"Is-a" relationship exam question  RSS feed

Bruno Negrao
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all, I found this is-a question in my Learn Key mock exam that i don't agree with the answer. The question and the answer are bellow:

A) is-a relationships always rely on inheritance.
B) is-a relationships always rely on instance variables.
C) is-a relationships always require at least two class types.
D) is-a relationships always rely on polymorphism.
E) is-a relationships are always tighly coupled.

Answers with explanations:
A, C and D are correct. B is incorrect. Inheritance is independent of the existence of instance variables. E is incorrect. Coupling is not used to evaluate classes within the same inheritance tree.

What i think from the answer:
A) A cannot be true because an is-a relationship also applies when a class implements an interface. Example: java.lang.String implements Comparable, then, String is-a Comparable! there is no inheritance!
C) i don't understand why we can't say that a String is-a String! Isn't it an is-a relationship?
D) i can't get why does is-a always rely on polymorphism, i think that's because of my doubt on letter C.

Can you clarify these with your comments?

Thank you,

Omer Haderi
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bruno,

A. is correct, because when you implement an interface you inherit all its methods and constants the interface may have. think of interfaces as a 100% abstract classes. (interfaces are the way that Java implements multiple inheritance).

C. the "is-a" refers to a relation so an object can NOT inherit it self. it may contain a reference to a reference of its type which is a "has-a" relationship but it can NEVER inherit itself.

D. Polymorphism is a Greek word and means "many forms" or "many shapes", regarding java that means that an object of type B that extends type A may be referred by references of type B of course BUT also by references of type A which means it has "many forms". So when when we speak for inheritance we also speak for polymorphism.


Hope to Help!

[ May 16, 2007: Message edited by: Omer Haderi ]
Anupam Sinha
Ranch Hand
Posts: 1090
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My view
A debatable
C Wrong
D Right

A) A is debatable. But I would had said true.

C) Now if A is correct then that includes interfaces. Now if interfaces are included then C should also include interfaces hence C is wrong.

D) Sounds true to me.

I guess this has been discussed before.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!