Hi, folks! The following question is - in my humble opinion - not precise: (#136)TRUE or FALSE: An inner class has free access to private member data of the outer class. Answer: TRUE Given a static inner class X and a non-static private member data Y located in the outer class of X, X will not be able to access Y. Therefore, question 136 should start with 'A non-static inner class has free access ...'. Best regards, Seraphin
There is still a loophole here - technically if a local class is declared inside a static method, static initializer, or static variable initialization expression, it is considered an inner class declared in a non-static context. Such a class does not have access to an enclsing instance, since there is none - and thus no member variables of the enclosing class can be accessed. But modifying the question wording to account for this case just tends to confuse people more than it helps, as it's a rather obscure example.
Originally posted by Jim Yingst: ...it is considered an inner class declared in a non-static context. Such a class does not have access to an enclsing instance, since there is none - and thus no member variables of the enclosing class can be accessed.
Did you mean ..."an inner class declared in a static context?" Rob
Rob
SCJP 1.4
Jim Yingst
Wanderer
Posts: 18671
posted 17 years ago
Yeah, something like that.
"I'm not back." - Bill Harding, Twister
Getting married means "We're in love, so let's tell the police!" - and invite this tiny ad to the wedding: