This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark ""Is-a" relationship exam question" Watch ""Is-a" relationship exam question" New topic
Author

"Is-a" relationship exam question

Bruno Negrao
Greenhorn

Joined: May 08, 2007
Posts: 2
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,

Bruno
Omer Haderi
Ranch Hand

Joined: Sep 27, 2006
Posts: 42
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.

ex:


Hope to Help!

Cheers.
[ May 16, 2007: Message edited by: Omer Haderi ]
Anupam Sinha
Ranch Hand

Joined: Apr 13, 2003
Posts: 1088
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: "Is-a" relationship exam question