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