This was one of the quiz question.
which variables may be referenced correctly in the iMethod ..
Correct Answer was :
A, B, C and E are correct. Since Inner is not a static inner class, it has a reference to an enclosing object, and all the variables of that object are accessible. Therefore A and B are correct, even if b is private. Variables in the enclosing method are only accessible when they are marked as final hence c is accessible but not d. E is obviously correct as it is a parameter to the method containing line 12 itself.
where option A - a, B-b, C-c D-d, E -e
I have added line 1 to 5 to check and I get an error on line 3 but not on line 4 and 5. According to answer, d is not accessible from imethod then where am I going wrong ? please someone help me to understand the concept of this variable reference.
The indent formatting of the code needs some work. The code indentation after the main() method's ending } makes it look like the code is inside of the main method.
The lack of indentation for the Inner class hides that it is inside of method()