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