Java: Is "reference variable of a class" same as "an object of that class"?
Is "reference variable of a class" same as "an object of that class"?
Also for a code like
int a, b;
public static void main(String arg)
// other statements
Among the variables a,b, c which are the class variables.
Is there a difference between variable a/b and variable c as far as their scope is concerned? Posted in: #Java
There is certainly scope difference between variable "a" and "c".
"a/b" are class/instance variables .
"c" is a local variable defined inside the method.
scope of "a/b" is associated to instance of class, object, just like method, in your program main() method.
Better go through full tutorial of varial type and do some practice.
Java - Variable Types
You question is confusing, what exactly you are looking far?
Reference variable is not same as Object.Both are different.
Object loads the non-static members (methods/variables) and the reference variable points to that object.Reference Variables are used for programmers convenience.
And in the above program,
a and b are called class variables.Also can be called as Non-static variables.
c is called static variable and is a local variable to main method.