Get the tools you need to learn Java skills fast!
Video tutorials, eBooks, hands-on lab exercises, sample code.
Get started
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 The Software Craftsman this week in the Agile 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: 453



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: 41631
    
  31
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
 
Have you tried LearnNowOnline? http://www.learnnowonline.com/
 
subject: Has-A relationsship explanation