aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes is-a relationship confusion Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "is-a relationship confusion" Watch "is-a relationship confusion" New topic
Author

is-a relationship confusion

Kevin Kilbane
Ranch Hand

Joined: Sep 22, 2008
Posts: 42
From MasterExam:

Which statements are true? (Choose all that apply)

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

Correct answers: A, C, D


I don't see how any of A, C or D are correct.

An Object object is an Object. There is only one class type in this statement and no inheritance or polymorphism applies. Please explain.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18990
    
  40


"IS-A relationship" is the ability of an object of one class type to behave as another class type. Just because you are able to form an english sentence with "is" followed by "a", doesn't mean that there is a "IS-A" relationship involved.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Sahil Kapoor
Ranch Hand

Joined: Sep 12, 2009
Posts: 316
Hey Kevin..... Only option "D" is correct in my sincere opinion.

Let me discuss my reasoning

A is Incorrect because it relies on Interfaces too... String is-a Serializable
B is incorrect because
C is incorrect , reasoning same a A. Serializable is not a Class , its an Interface.
D is correct, it relies on polymorphism . (always word is somehow debatable as your example seems to be correct, Object is-a Object and does not involve polymorhism, but IMO it is a particular special case. )
E. Coupling has nothing to take with is-a, as two classes may be coupled (tightly or loosely) without being in same Inheritance tree.

Thanks !!!

In actual exam you will get, how many are true....then you can move from most obvious to least.

I agree with you all are incorrect !!! (always word seems to be wrong, it should be most of the time)

SCJP 6.0 96%

(Connecting the Dots ....)
Kevin Kilbane
Ranch Hand

Joined: Sep 22, 2008
Posts: 42
Henry Wong wrote:
"IS-A relationship" is the ability of an object of one class type to behave as another class type. Just because you are able to form an english sentence with "is" followed by "a", doesn't mean that there is a "IS-A" relationship involved.

Henry


Thnaks for the prompt reply Henry.

Have a look at this method:


Statement 1: "The parameter to the doStuff method must be an object that passes the IS-A Car test".

Statement 2: "The parameter to the doStuff method must be a Car object or an object that passes the IS-A Car test".

I always thought statement 1 was correct but you are saying that statement 1 is incorrect and statement 2 is correct.

Is that right?

Kevin Kilbane
Ranch Hand

Joined: Sep 22, 2008
Posts: 42
Henry Wong wrote:
"IS-A relationship" is the ability of an object of one class type to behave as another class type. Just because you are able to form an english sentence with "is" followed by "a", doesn't mean that there is a "IS-A" relationship involved.

Henry


Sorry, did some further checking after I posted the last reply. The Bates and Sierra book states in Chapter 2 (top p.95 in my copy):

"Other than objects of type Object, all Java objects are polymorphic in that they pass the IS-A test for their own type and for class Object."

The important bit here is "they pass the IS-A test for their own type" i.e. String IS-A String.

I'm still leaning towards thinking the answers in MasterExam are wrong.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: is-a relationship confusion