class A{
static int a=5;
int b=6;
void method(){
//method body
a++;
}
}
How JVM handles static variable handles static variable. for example...
A object1=new A();
A object2=new A();
Above code will create two objects of class A in two different memory location. Also two instance of variable b
will be created. What will happen for variable a
. which object will hold the reference for the static variable? and what happen when we update static variable?