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  question from sun 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 " question from sun" Watch " question from sun" New topic

question from sun

anushree ari
Ranch Hand

Joined: Sep 30, 2002
Posts: 98
class A {}
class B {
private A myA = new A();
Which two statements are true about the relationship between class A and class B? (Choose two.)

A maintains no relationship with B

B maintains no relationship with A

B maintains a "one to many" relationship with A

The relationship can be described with a has-a clause

The relationship can be described with an is-a clause

i choose "is" a relationship, but ans is "has " a relationship.
anybody correct me

david eberhardt
Ranch Hand

Joined: Jul 02, 2002
Posts: 158

class B can have member variables, methods, and also contain other objects as members.
What we have here is an example of class A being used as a member of class B because there is some (undefined) functionality we want to use in our class B.
An similar example might be:
class Wheel {
class Car {
Wheel rightFront = new Wheel();
Wheel leftFront = new Wheel();
a Car has-a wheel ( actually has 4 of them right?)
an IS-a relationship is about inheritence:
class Animal {
boolean canFly = false;

class Bird extends Animal {
boolean canFly = true;
fly() {
// implementation top secret
I agree. Here's the link:
subject: question from sun
It's not a secret anymore!