File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Object  Orientation" Watch "Object  Orientation" New topic

Object Orientation

Ikechukwu Morah

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="" target="_blank" rel="nofollow">Try my mock exam.</a>
I agree. Here's the link:
subject: Object Orientation
It's not a secret anymore!