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