This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Getting MEAN with Mongo, Express, Angular, and Node and have Simon Holmes on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Object  Orientation 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 "Object  Orientation" Watch "Object  Orientation" New topic
Author

Object Orientation

Ikechukwu Morah
Greenhorn

Joined: Nov 01, 2002
Posts: 18
What type of relationship is represented by the code snippets below:
A. public class Species {}
public class Animal {
private Species species;
}
B. interface Component {}
class Container implements Component {
private Component [] children;
}
Dan Chisholm
Ranch Hand

Joined: Jul 02, 2002
Posts: 1865
The relationship between Animal and Species is a "has-a" relationship because Animal "has-a" Species.
The relationship between Container and Component is an "is-a" relationship because Container implements Component. A "has-a" relationship also exists because Container has a field that is an array of Container.


Dan Chisholm<br />SCJP 1.4<br /> <br /><a href="http://www.danchisholm.net/" target="_blank" rel="nofollow">Try my mock exam.</a>
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Object Orientation