Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java different type of relationship among classes

 
Amanda Mosby
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am confused about what are different relationship termed when

1) when a class extends another class
2) when a class implements interface
3) when a class have another class object as data member

are there any other kind of relationship?

I also found this Has-A Relationship at codeRanch, but answers here confuse more than before
 
Matthew Brown
Bartender
Posts: 4566
8
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1 and 2 are both IS-A relationships, whereas 3 is usually termed a HAS-A relationship.

I'd say there are also relationships when:

- a class creates an instance of another class
- a class has a method taking a parameter of another class
- a class has a method returning an instance of another class

I'm not sure I've heard specific names for those relationships, though. Maybe "USES"?
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not quite sure what you want. Do you simply want to know what they are called?

This YouTube link seems promising, I have only watched the first 5 minutes.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic