Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

K&B question

 
Reghuram Variyam
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This from new edition of K&B scjp 1.5. In chapter 2, the first question of self test is like this

Which Statements are true ?

A.Has-a relationship always rely on inheritance
B.Has-a rel. always rely on instance varables
C.Has-a rel. always require at least two classes
D.Has-a rel. always rely on polymorphism
E.Has-a rel. always tightly coupled.

The correct answer given in teh book is 'B'. But if a class has a Static reference to another object, that is also considered as Has-a rel. correct ?
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's a good point, because in that case all instances of the class "have" the object referenced by the static (or class) reference variable.

Other opinions?
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Barry Gaunt:
...in that case all instances of the class "have" the object referenced by the static (or class) reference variable...

That's how I understand it.
 
Reghuram Variyam
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With the given options, it looks like there is no correct answer to that question ???
 
Suguna Gollapally
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ie Class (static) variable can also be used to define the Has-A relationship
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic