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