aspose file tools*
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


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark " question from sun" Watch " question from sun" New topic
Author

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
thx


anushree
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: http://aspose.com/file-tools
 
subject: question from sun
 
Similar Threads
sample question on Sun website
relationship between classes
has-a. equals (maintains No Relationship)
HAs-a Relationship Problem SCJPTEST
question about "has a" at SUN's mock exam