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