wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Has-A relationsship explanation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Has-A relationsship explanation" Watch "Has-A relationsship explanation" New topic
Author

Has-A relationsship explanation

ranjan sarkar
Greenhorn

Joined: Jun 30, 2008
Posts: 7
Q)Man has a best friend who is a Dog
How you can explain this with Has-A relation
avi sinha
Ranch Hand

Joined: Mar 15, 2009
Posts: 452



Man has a bestFriend. hence man will have a bestfriend variable.
......who is a Dog. hence bestFriend is an instance of class Dog.

avi sinha


SCJP 5.0 SCWCD 5.0
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38042
    
  22
The Man-Dog example is called "association"; a Man does not cease to be a Man if the Dog dies.

The examples I have given are called "composition"; an Aeroplane without a Wing is no longer an aeroplane in the fullest sense of the word. And if you disagree, try taking the wings off your aeroplane at 29000 feet
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Has-A relationsship explanation
 
Similar Threads
Where is the values() method documented for Enum?
india shopping site question
sheet for number of correct answers of hfsj final mock !
Whats your best movie
who has the weblogic451