A variable in java is something that holds a value and has a name attached to it. This value can change and hence its named a variable.
There are two types of variables in Java:
• Primitives - A primitive variable can be one of eight types: char, boolean, byte, short, int, long, double, or float. Once a primitive has been declared, its primitive type can never change, although in most cases its value can change.
• Reference variables - A reference variable is used to refer to (or access) an object. A reference variable is declared to be of a specific type and that type can never be changed.
Java does not have the concept of Reference Variables. We cannot access the memory location where the data is stored 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.
yes we can define a variable in an interface in java.
Java does not have the concept of Reference Variables. We cannot access the memory location where the data is stored in Java.
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.
yes we can define a variable in an interface in java.
no
Yes. You can have as many variables as you want in Java
Member Variables
No, they are not.