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