• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Two questions about mock exam

 
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic