Given the following code:
public class VenCengswo {
public static void main(String[] args) {
VenCengswo v0 = new VenCengswo();
A
VenCengswo v1 = new VenCengswo();
v0.xesa(1);
v1.xesa(10);
v0 = v1;
v1 = new VenCengswo();
v0.xesa(100);
v1.xesa(1000);
B
}
private static int ued = 0;
private int soo = 0;
public void xesa(int ee) {
int ut = 0;
soo += ee;
ut += ee;
ued += ee;
System.out.println("soo=" + soo + " ut=" + ut + " ued=" + ued);
C
}
}
ued, soo, ut, v0, v1] are in scope at A ?Output:
ued=1 soo=1 ut=1 ued=10 soo=10 ut=11 ued=110 soo=100 ut=111 ued=1000 soo=1000 ut=1111
In scope at A : ut, v0, v1
In scope at B : ut
In scope at C : ut, ued
Explanation (which you do not need to write out in your submitted solution):
ut is a static variable, ued is an instance variable, and soo is a local variable.
At A , ued is out of scope because it is an instance variable, but main is a static method. soo is out of scope because it is local to xesa.
At B , v0 and v1 are out of scope because they are not declared yet. ued is out of scope because it is an instance variable, but main is a static method. soo is out of scope because it is local to xesa.
At C , soo is out of scope because it is not declared yet. v0 and v1 out of scope because they are local to the main method.
Related puzzles: