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