• 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

Inner Class

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which of the follwing is true?
1. inner class can be instantiated only in it's enclosing class
2. they can be accessed only within the enclosing class
3. they cannot implement interface
4. they can access final varaibles and final methods within their declaration
scope
5. Top level nested class need not be instantiated
My ans is 4. I am not sure about 5.
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
5 is true too. There is no such thing as a class
that MUST be instantiated.
This whole question is kind of weirdly stated and
I wonder where you got it. Question 4 is especially
odd. What's the point? A non-static inner class
can access *any* variable of its parent instance.
 
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just a free association, a local inner class can have access to only final fields that's declared in the enclosing method. Maybe that was the intended relevance.
reply
    Bookmark Topic Watch Topic
  • New Topic