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