• 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

method local inner class question from marcus green mock exam 1

 
Ranch Hand
Posts: 469
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

The ans given is 1,2,3
But none of the answers are correct right?Coz method local inner class can't be declared as public,private,protected,static,as class is defined locally inside a method.Please correct me if I am wrong.
Thanks
Veena
 
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you got some confusion with ordinary classes and inner classes.The ordinary class you can have no modifies other than public.In case of Inner classes u can have private, protected, public, default and static. U can refer with JLS for confirmation and plz read K&B, you will get every thing clear on this
Vivek Nidhi
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Veena --
You're right, method-local inner classes can't be public, protected, private or static. But looking at the code you've shown here, the inner class is outside of main(), at class scope; it's not a method-local class at all. Such a class can indeed have all these modifiers.
 
reply
    Bookmark Topic Watch Topic
  • New Topic