How a Java variable would act depends on the variable's data type. Variables of the primitive data types like int, char, float etc would not act as objects. But apart from them, all other data types would act as Objects. Almost all data types would extend from java.lang.Object and would behave as objects.
Member variables.
Java does not have the concept of Reference Variables. We cannot access the memory location where the data is stored in Java.
Instance variableA variable, part of an Object. These might better be called perObject variables since each instantiated object of this class will have its own private copy of this variable. They are allocated when the object is allocated via new. Static methods may not access the instance variables of their class (or any other class for that matter), other that via some object reference, e.g. anObject.someField. Static methods may even access private instance variables in their class via some object reference.
There are two main categories of variables in Java. They are primitive and non primitive. Primitive data types are the basic data types like int, float, char etc. These are not objects. The other non primitive data types are all types of Java Objects. Example: String, ArrayList etc.
At any given point of time you cann't get the address of a variables of java program. This is meant for security purpose only.
Member variables.
"this" is a Java keyword that references the current object. Any part of the object(instance variables, methods, constructors) can be accessed by calling this.[member].
objects are instances of class only and moreover objects are object reference variables extension of variables is meaningless so objects in java can't be extend
Java does not have the concept of Reference Variables. We cannot access the memory location where the data is stored in Java.
Instance variableA variable, part of an Object. These might better be called perObject variables since each instantiated object of this class will have its own private copy of this variable. They are allocated when the object is allocated via new. Static methods may not access the instance variables of their class (or any other class for that matter), other that via some object reference, e.g. anObject.someField. Static methods may even access private instance variables in their class via some object reference.
There are two main categories of variables in Java. They are primitive and non primitive. Primitive data types are the basic data types like int, float, char etc. These are not objects. The other non primitive data types are all types of Java Objects. Example: String, ArrayList etc.
no
Global variables are globally accessible. Java does not support globally accessible variables due to following reasons:The global variables breaks the referential transparencyGlobal variables creates collisions in namespac
There's no global variables in Java.
At any given point of time you cann't get the address of a variables of java program. This is meant for security purpose only.
Reference variables
No, static variables are not serialized.