Given the following code:
public class CelChelmer {
public void gaegal(int me) {
int tre = 0;
A
a += me;
tre += me;
iupa += me;
System.out.println("a=" + a + " tre=" + tre + " iupa=" + iupa);
}
private int iupa = 0;
public static void main(String[] args) {
CelChelmer c0 = new CelChelmer();
B
CelChelmer c1 = new CelChelmer();
C
c0.gaegal(1);
c1.gaegal(10);
c1 = new CelChelmer();
c0 = c1;
c0.gaegal(100);
c1.gaegal(1000);
}
private static int a = 0;
}
iupa, a, tre, c0, c1] are in scope at A ?Output:
iupa=1 a=1 tre=1 iupa=11 a=10 tre=10 iupa=111 a=100 tre=100 iupa=1111 a=1000 tre=1100
In scope at A : iupa, tre, a
In scope at B : iupa, c0, c1
In scope at C : iupa, c0, c1
Explanation (which you do not need to write out in your submitted solution):
iupa is a static variable, tre is an instance variable, and a is a local variable.
At A , c0 and c1 out of scope because they are local to the main method.
At B , tre 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 gaegal.
At C , tre 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 gaegal.
Related puzzles: