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