permaculture playing cards*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Class declaration Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Class declaration" Watch "Class declaration" New topic
Author

Class declaration

Vishakha Ahuja
Ranch Hand

Joined: Sep 13, 2000
Posts: 191
Many books mention that a "Top Level" java class can be public or not public (i.e not declared with any access modifier). What about the modifiers protected and private, can they be used with top level class ?
Ajith Kallambella
Sheriff

Joined: Mar 17, 2000
Posts: 5782
Nope. Top level classes can only be public/default. No other access modifiers permitted....try it out yourself!
Ajith


Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
Vishakha Ahuja
Ranch Hand

Joined: Sep 13, 2000
Posts: 191
Thanks Ajith.
J. Macha
Greenhorn

Joined: Sep 14, 2000
Posts: 12
What about a private static inner class.
a static inner class is considered a top level class and it can be private.
Ramesh Donnipadu
Ranch Hand

Joined: Sep 16, 2000
Posts: 100
static inner classes (private or otherwise) are top level nested classes. They are not top level classes.
Top level classes are package level classes with only package as enclosing context.
jag_nai
Greenhorn

Joined: Sep 16, 2000
Posts: 21
That was nice, Thanks Ramesh!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Class declaration