• 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

Doubt in Access modifiers for classes

 
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What are the specifications for defining access specifier for classes. If I have a top level class with default accesbility then how do I know what accessbility can the inner class defined in it can have? Same goes with interface.
I know that we can not define any access specifiers for local classes as they are accessible within the method only. But what about interfaces nested within classes and vice versa. I'm really confused...

Please help...
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


This is an example I created because I was not 100% sure as well. It seems the inner class or interface can have any access modifier and still compile.

Edit : Code changed. To extend on this a bit, I also wanted to see scope/instantiation. Test2 will not compile due to interface c being private.
[ October 27, 2006: Message edited by: Matthew Gerald ]
reply
    Bookmark Topic Watch Topic
  • New Topic