aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes K&B static/instance variable clarification Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "K&B static/instance variable clarification" Watch "K&B static/instance variable clarification" New topic
Author

K&B static/instance variable clarification

Ajit Sawant
Ranch Hand

Joined: Nov 26, 2008
Posts: 33
Hello,

On page 217 (chapter 3), part of the code is as follow:
class Foo{
static int size=7;
.... rest of the code.
The description on the page calls the varibale size as an instance variable. Isn't this a class variable as it marked static?
Please clarify.
Thanks in advance.
Ajit
Ajit Sawant
Ranch Hand

Joined: Nov 26, 2008
Posts: 33
In the above question, I'm referring to SCJP6 book by Kathy and Bert.
Thanks
Ajit
patrick avery
Ranch Hand

Joined: Sep 12, 2008
Posts: 46
I think you are correct.


SCJA 96%
SCJP 6 88%
skipping SCJD to work on passing SCWCD
Rajshekhar Paul
Ranch Hand

Joined: Oct 17, 2006
Posts: 140
By looking at the program, I can say that it's a typo when the author explained the code. It should be mentioned as static variable as in the main method the variable is directly accessed without using the class instance.


When it's obvious that you have to do it, just do it without shattering your thoughts over different directions.
Bert Bates
author
Sheriff

Joined: Oct 14, 2002
Posts: 8815
    
    5
Egads! I think you're correct. It's amazing how long stuff like that can sit there, in thousands of copies of books, across several editions of authoring, editing and reviewing, and never be found!

Anyway, thanks for the (very likely), catch, I've marked in my book.

Bert


Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: K&B static/instance variable clarification