Page 1 of 1
About Question enthuware.ocpjp.v8.2.1893 :
Posted: Mon Apr 25, 2016 3:35 am
by schchen2000
If the inner class is non static, all the static and non-static members of the outer class are accessible (otherwise only static are accessible) So option 1, 2 are valid.
The above quote is from the Explanation part of the question.
If the inner class is non static,....
and
....otherwise only static are accessible....
seem to allude that a static class is allowed inside a method.
To the best of my understanding, no class or variable is allowed to be static inside any method.
Am I missing something here? Thanks.
Schmichael
Re: About Question enthuware.ocpjp.v8.2.1893 :
Posted: Mon Apr 25, 2016 9:40 am
by admin
The statement starts with, "If the inner class is non static...". Therefore, the otherwise part (i.e. "otherwise only static are accessible") clearly implies that it is talking about the case when an inner class is static. It is a general statement and not for a particular option.
I do not see how the statement implies that a static class is allowed inside a method. The statement is just giving you a simple way to find out which variables are accessible when. It is not talking about anything else.
HTH,
Paul.
Re: About Question enthuware.ocpjp.v8.2.1893 :
Posted: Mon Apr 25, 2016 12:46 pm
by schchen2000
admin wrote:The statement starts with, "If the inner class is non static...". Therefore, the otherwise part (i.e. "otherwise only static are accessible") clearly implies that it is talking about the case when an inner class is static. It is a general statement and not for a particular option.
I do not see how the statement implies that a static class is allowed inside a method. The statement is just giving you a simple way to find out which variables are accessible when. It is not talking about anything else.
HTH,
Paul.
Thanks. A static class is not allowed in a method anyway. Is that correct?
Schmichael
Re: About Question enthuware.ocpjp.v8.2.1893 :
Posted: Mon Apr 25, 2016 7:59 pm
by admin
That is correct.
Re: About Question enthuware.ocpjp.v8.2.1893 :
Posted: Fri May 20, 2016 11:38 pm
by schchen2000
admin wrote:That is correct.
Thanks. Sorry about being a bit late.

Re: About Question enthuware.ocpjp.v8.2.1893 :
Posted: Wed Sep 13, 2017 2:59 am
by excluzzzive
Hello,
your explanation about
criteria answer is:
Even though this variable is local to the method, it is accessible in the inner class defined inside the method because it is declared as final.
But is this correct? Won't it work without final, because in this code snippet it is effectively final?
Re: About Question enthuware.ocpjp.v8.2.1893 :
Posted: Wed Sep 13, 2017 7:49 am
by admin
No, criteria is not effectively final. It is final. count, on the other hand, is effectively final. Both will be accessible as the explanation notes.
Re: About Question enthuware.ocpjp.v8.2.1893 :
Posted: Wed May 08, 2019 3:48 pm
by robiwan
There IS an assumption that the effectively final variable count is . not used in the various '// lots of code' segments, which I find a bit misleading
Re: About Question enthuware.ocpjp.v8.2.1893 :
Posted: Wed May 08, 2019 10:19 pm
by admin
Will Update to avoid this confusion.
thank you for your feedback!