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