• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Isn't this contradictory ?

 
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Page 1 of section[4.5] Marcus Green tutorial states:-

"Essentially a class level variable will always be assigned a default value and a member variable (one contained within a method) will not be assigned any default value. "

but

"Certified Programmer & Developer for Java 2 Study Guide...by Kathy Sierra and Bates " states on page 33[1st chapter- Language fundamentals]:-
Instance variables[ also called as member variables] are variables defined at the class level.

Isn't this contradictory ?
 
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Netty,

Here are my views...


"Essentially a class level variable will always be assigned a default value and a member variable (one contained within a method) will not be assigned any default value. "



I wouldn't call member variable which is within a method. Variables within a method are called local variables and they need to be initialized before you use them.
I perfectly agree with Kathy & Bert's terminology for member variables
 
Jay Pawar
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Typo...
I meant to say I wouldn't call a variable which is within a method as MEMBER variable. I believe it's a local variable
 
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is a difference in termanology here.

Instance Variables = member variables = class level variable
local variable = METHOD variables = are defined within a method.



From the code snippet above, you can see the userName variable is an instance variable or a member variable. The aVariable variable in doSomething is a method variable.

Hope this helps
 
Jay Pawar
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Netty,
I would appreciate if you could give me a link to Marcus Green tutorial ?
Thanks in advance
 
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just as my own nitpick, be careful when you refer to "class-level" variables. When someone says "class-level" to me, I immediately think static variable. The terminology I use is like this, and usually seems to be appropriate:

Local Variable - A variable defined within a method
Instance Variable / Member Variable - A non-static variable declared within a class
Class Variable / Static variable - A static variable declared within a class
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jay Pawar:
Netty,
I would appreciate if you could give me a link to Marcus Green tutorial ?
Thanks in advance




Marcus' Java Certification HeadQuarters (JCHQ)

I started out there before I came over to JavaRanch. Marcus has helped a lot towards my SCJP 1.4 - especially the Question Of The Day
 
Netty poestel
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Marcus tutorial page URL [Objective 5, Unassigned variables]:-

http://www.jchq.net/certkey/0405certkey.htm

and thx. all for all the feedbacks.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic