This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
1��which one is true? A.An anonymous class can be declared as static. B.A static inner class cannot be a static member of the outer class. C.A static inner class does require an instance of the enclosing class. D.Instance member of a static inner class can be referened using the class name of the static inner class. 2��which statement is true? A. An anonymous inner class may be declared as final B. An anonymous inner class can be declared as private C. An anonymous inner class can implement mutiple interfaces D. An anonymous inner class can access final variables in any enclosing scope E. Construction of an instance of a static inner class requires an instance of the encloing outer class the first question's answer is c,and the second question's answer is d,but I don't think so.please explain it to me!thanx
D. An anonymous inner class can access final variables in any enclosing scope Basically an anonymous class have direct access to all members in the enclosing context whether they are declared as final or not. In the case of local method variables, since the anonymous object can continue to exist longer than local method variables, the anonymous object is not permitted to access local method variables unless the variable is declared final and is assigned a value before the declaration of the local or anonymous class. The JVM can place a copy of the value of the final variable directly into the local or anonymous class so there is no further dependence on the method variable. Hope that makes sense. [ November 27, 2002: Message edited by: Roan Nicolas ]