aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Doubt in Access modifiers for classes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Doubt in Access modifiers for classes" Watch "Doubt in Access modifiers for classes" New topic
Author

Doubt in Access modifiers for classes

Shyam kumar
Ranch Hand

Joined: May 21, 2006
Posts: 146
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...
Matthew Gerald
Greenhorn

Joined: Sep 11, 2006
Posts: 10


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 ]

-------------------------<br />SCJP 1.4 10/28/2006<br />SCWCD (next on the list!)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubt in Access modifiers for classes