Given:
public class ScopeTest1 {
public static void main(String[] args) {
doStuff(); // line x1
int x1 = x2; // line x2
int x2 = j; // line x3
}
static void doStuff() {
System.out.println(j); // line x4
}
static int j;
}
Which line causes a compilation error?
A.
line x1
B.
line x2
C.
line x3
D.
line x4
Explanation:
The variable x2 is used before it has been declared.