• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

is-a relationship confusion

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
author
Posts: 23931
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

"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
 
Ranch Hand
Posts: 316
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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)
 
Kevin Kilbane
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic