posted 22 years ago
First off, the code won't compile because the final variables p and j haven't been initialized. So if one of the answers is, "Code will not compile", that would be the one. But assuming those are simply big mistakes, and that you are to assume they've been taken care of..
the method-local inner class (Inner) has access to i and j, because they're instance variables of the outer class. And it also has access to m because its final. In fact, the only thing it does NOT have access to is 'k'.
The inner class can see "n" and "p" (the final on p makes no difference here) because both n and p are instance variables of the inner class, NOT local variables within the method itself. In other words, if you moved the declaration of n to become the first statement in the method (so, above/outside the inner class declaration) then indeed, n would not be accessible because its not final (and thus would be blown off the stack potentially long before the inner object was killed).
cheers,
Kathy