56. „A local inner class can be accessed by the methods of an inner class only if it is _________ Anwer: „final“ A local variable is only visible inside the method. So now method outside the method can access the local variable. Therefore the inner class has to be inside that method where the local variable is defined. Therefore the inner class which can access a local variable must be a local or anonymous class because theses classes are inside methods. Local inner classes can only access local variables of the enclosing methods if they are final or parameter arguments. Do you think my answer is correct? Thomas
The original question seems to be nonsense. It's not talking about accessing a local variable, but rather a local class. Evidently this access would occur from another inner class. The only way I can imagine this working is if both inner classes are local or anonymous, defined inside the same method (or constructor or initializer), and if the class to be accessed is also final. This involves a lot of unstated assumptions that don't fit easily into the answer blank; I'd assume that either (a) the question is miscopied, or (b) the question author doesn't know what they're talking about. If it's the latter case, I wouldn't spend time worrying about what they meant. Note that if we replace the original question with "A local variable can be accessed by the methods of an inner class only if it is _________" then your answer is correct.