File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Can a top level class be private ? 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 "Can a top level class be private ?" Watch "Can a top level class be private ?" New topic
Author

Can a top level class be private ?

Rekha Suri
Greenhorn

Joined: Mar 22, 2000
Posts: 15
Can a top level class be declared private or protected ? This is from the Round Up game in this site. Any clarification will be helpful.
Thanks.
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
Try making one, and see what the compiler will let you.


"I'm not back." - Bill Harding, Twister
Nilesh Parikh
Ranch Hand

Joined: Mar 14, 2000
Posts: 52
hi
the only access modifier that can go with the top level class is public. you can not make the top level class private or protected
ALkesh
Nalini Mistry
Ranch Hand

Joined: Mar 21, 2000
Posts: 64
private and protected cannot be used with classes
Javix Protocol
Ranch Hand

Joined: Mar 21, 2000
Posts: 57
Hey u can use the keywords in methods and variables for the purpose of encapsulation and managing abstraction through that.
But giving the same to a class name suggests that u are reducing ur portability .See whether u can make the keywords in innerclass
since their they might be useful for the encapsulation of class members.Adieu..


Write Once , Run Anytime ,Anywhere Forever And Smile Happily.
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Actually, private and protected may be used as access modifiers for inner or nested classes. Marcus Green's tutorial has been updated to reflect this fact.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can a top level class be private ?