• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

K&B question

 
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 ?
 
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?
 
Sheriff
Posts: 11343
Mac Safari Java
  • 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 ???
 
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
 
If I'd had more time, I would have written a shorter letter. -T.S. Eliot such a short, tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic