• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Adjectives for "variable" - automatic/local/member/method/method level/instance/class

 
Meena
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a variety of different Java materials and books in which variables are described with completely different adjectives. I just wish there was a concensus.
Which of these words mean the same exact thing, and what specifically do they mean?
"automatic" variable
"local" variable
"member" variable
"method" variable
"method level" variable
"instance" variable
"class" variable
Question 1: If I wanted words to describe variables that are in a class body but outside of methods or constructors, wich of the above adjectives would I use?
Question 2: If I wanted words to describe variables that are in a method body within a class, which of the above adjectives would I use?
Question 3: If I wanted words to describe variables that are in a class within another class, which of the above adjectives would I use?
Question 4: Is there another category that I didn't mention in Question 1 - Question 3 above?

Thanks!
 
Thandapani Saravanan
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Ans(1) :
Variables that are declared inside the class are called member variables. A member variable could either be class variable (if it is declared as static) or an instance variable (if it is not declared as static).
Ans(2):
Variables that are declared inside a block or for loop are called local variables. (in c, we used to call this automatic variable)
I don't know which book you are referring to when you say method level variable. As for as words are concerned the authenticated book, i belive is
The Java Language Specification
by
James Gosling
Bill Joy
Guy Steele.
Good luck,
Saravanan
------------------

 
paul wheaton
Trailboss
Pie
Posts: 21388
Firefox Browser IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Q1: class attribute
Q2: local variable
Q3: class attribute
Q4: Parameters.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic