*
The moose likes Beginning Java and the fly likes Confused with a particular sentence in Kathry's and Bert's Book Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Confused with a particular sentence in Kathry Watch "Confused with a particular sentence in Kathry New topic
Author

Confused with a particular sentence in Kathry's and Bert's Book

Hussain Sabir
Greenhorn

Joined: Mar 26, 2007
Posts: 3
Which statement(s) are true? (Choose all that apply.)
A. Has-a relationships always rely on inheritance.
B. Has-a relationships always rely on instance variables.
C. Has-a relationships always require at least two class types.
D. Has-a relationships always rely on polymorphism.
E. Has-a relationships are always tightly coupled.
Answer:
® 3 B is correct.
®˚ A and D describe other OO topics. C is incorrect because a class can have an instance of
itself
. E is incorrect because while has-a relationships can lead to tight coupling, it is by no
means always the case. (Objective 5.5)
2. Given:
class Clidders

Guys ,

I'm not able to convince my mind with answer C above,could anyone please give me an example for this kind of Has-A relationship.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30386
    
150

Suppose you have a bag class. It could have an attribute for another bag. (I smaller one that you roll up and put inside.) So a Bag would "have" a Bag. One class.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11256
    
  16

another example would be a linked list. each node has-a reference to a previous or a next node.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Hussain Sabir
Greenhorn

Joined: Mar 26, 2007
Posts: 3
That explains everything(Wondering, why I didn't thought this way,probably because my Brain battery was down last night ).
cheers guys, Javaranch Rocks!!
 
wood burning stoves
 
subject: Confused with a particular sentence in Kathry's and Bert's Book