*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Two questions about mock exam Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Two questions about mock exam" Watch "Two questions about mock exam" New topic
Author

Two questions about mock exam

dragon ji
Ranch Hand

Joined: Oct 31, 2002
Posts: 110
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


scjp 1.4<br />challenge haven't limit!
Roan Nicolas
Greenhorn

Joined: Nov 11, 2002
Posts: 23
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 ]

Owee<p>SCJP 1.4
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Two questions about mock exam
 
Similar Threads
some questions of anonymous inner class
Inner class/anonymous
question about static inner classes
Anonymous Inner class
anonymous inner class question