It's not a secret anymore!
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes a true or false statement 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 "a true or false statement" Watch "a true or false statement" New topic

a true or false statement

adam Lui
Ranch Hand

Joined: Sep 03, 2007
Posts: 186
A has-a relationship can be established by using ojbect reference variables a as local variables.

true or false. Why?
[ October 19, 2007: Message edited by: adam lui ]
palla sridhar
Ranch Hand

Joined: Oct 15, 2007
Posts: 111
Hi Adam!
It was a nice question to ask. As far as i know, if a class contains object reference variable as instance variable, then that's a HAS-A relatinship. For example: means Animal HAS-A Dog.

If you also check K&B, there is also an example like this:.
The book says that
Users of a Horse should not even need to know that there is such a thing as a Halter class.

So if you go by this explantion, users of a class dont even need to know that there is a local object reference variable, which implies that local object reference variables also follow HAS-A relationship.

So my answer is TRUE and for why? above is the explanation..
This is what i think, anybody please correct me if i'm wrong!!

Thanks and Regards,
*Nothing is CONSTANT in life, except CHANGE*
Rahul Shilpakar
Ranch Hand

Joined: Aug 29, 2006
Posts: 132
yes its true

Perform for today. Adapt for tomorrow.
I agree. Here's the link:
subject: a true or false statement
It's not a secret anymore!