I have a slight problem with the following question on the Rules Round Up Game
-----------------
TRUE or FALSE : a static inner class (considered a top - level nested class) can NOT access non-static variables of the outer class.
---------------
The correct answer, as given by the tester is TRUE. But I am of the opinion that it should be FALSE because as a matter of fact, a static inner class may access non static variables of the outer class if an instance of the outer class is used to retrieve the variable as in
------------
class Outer {
private theValue = 20;//non static variable of Outer
public static void main(
String[] args){
Inner inner = new Inner();
}
static class Inner {
Inner(){
//Lets attempt to access non static variable of
//Outer class from this static inner class
System.out.println(new outer().theValue);
}
}//End of Inner Class
}//End of Outer Class
I appreciate the concept that I think this question is trying to access, but I thought it would be more accurate if it included "without using an instance of the outer class".
Tell me what you think about this and for the sake of the exam which I am preparing for, please advise on what to answer if I meet a question with such wording.
Thanks comrades.