Variables in java
Based on the type of value represented by the variable all variables are divided into two types : Primitive variables: can be used to represent primitive values. Example: int x =10; Reference variables: can be used to refers to objects Example: Studen s = new Studen(), s is pointing to object. Based on the position of declaration and behavior variables are divided into three types: Instance : the value of the variable is varied from object to object such type of variable is called instance variables. for every object separate copy of the instance, a variable will be created. Instance variable should be declared within a class directly but outside of any method or block or constructor. instance variable will be created at the time of object creation and destroyed at the time of object destruction hence the scope of the instance variable is exactly the same as the scope of the object. The instanced variable will be stored in the heap memory as part of the object. we cant access th...