• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

has-a and static variables

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In the K&B Book is the answer of Self Test Questin 1 in Chapter 2:
Has-a relationships always rely on instance variables.

And what is about class (static) variables. Isn't that a has-a relationship, too?

Greetings
J�rg
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
please send correct question no.
 
Joerg Waldmann
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's in the SCJP 310-055, self test chapter 2, Question no 1.
The wright answer ist B, has-a relationship always rely on instance variables.

I think, has-a relationship rely on class variables, too.
 
Ranch Hand
Posts: 286
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The static var exists before an instance is made...what object does have them, then? You can't have a Has-a relationships with the static var.
Im still studying maybe Im wrong but I dont think so.
I hope you understand what I mean...
 
Joerg Waldmann
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The definition of has-a in the book is: In Instance, that has a reference to the instance of another class.
So, in my opinion, a class variable is a reference to an instance, too. It's just the same instance for all objects of this class.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic