To answer this question, let's go through the code:
public class Outer {
private String x = "Outer variable";
void doStuff() {
String z = "local variable";
class Inner {
public void seeOuter() {
System.out.println("Outer x is " + x);
System.out.println("Local variable z is " + z);
}
}
}
}
In this code, the class Outer contains a method doStuff() which declares a local variable z of type String.
Inside the doStuff() method, there is also a nested class Inner which has a method seeOuter().
The seeOuter() method tries to access the variables x and z from the enclosing Outer class. However, it is important to note that local variables, like z, are only accessible within the method they are declared in.
Therefore, when trying to access the local variable z from the seeOuter() method, it will result in a compile error because z is not in scope.
So, the correct answer is:
B. Compile Error