Java: Is "reference variable of a class" same as "an object of that class"?

In context to Java programming,

Is "reference variable of a class" same as "an object of that class"?

Also for a code like

class Sample
{
int a, b;
public static void main(String arg[])
{
int c;
// 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?

Replies

Welcome, guest

Join CrazyEngineers to reply, ask questions, and participate in conversations.

CrazyEngineers powered by Jatra Community Platform

  • Anoop Kumar

    Anoop Kumar

    @anoop-kumar-GDGRCn Feb 18, 2016

    I assume you like to know the difference between, Instance variable and local variable.

    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.
    <a href="https://www.tutorialspoint.com/java/java_variable_types.htm" target="_blank" rel="nofollow noopener noreferrer">Java - Variable Types</a>

    You question is confusing, what exactly you are looking far?