File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Top Level Class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Top Level Class" Watch "Top Level Class" New topic

Top Level Class

noel angel
Ranch Hand

Joined: Oct 27, 2002
Posts: 75
I know that top level classes may not be private or protected but would somone please explain exactly what is a top level class???exactly
Dan Chisholm
Ranch Hand

Joined: Jul 02, 2002
Posts: 1865
A nested class is any class that is declared inside the body of another class or interface. A top-level class is a class that is not a nested class.
A top level class can be declared with public or package (default) access. It can be declared final so that it can not be extended. It can be declared abstract meaning that it might contain an abstract method declaration and can not be instantiated. It can also be strictfp meaning that all float and double expression in all nested classes, methods, constructors, and static, instance, and variable initializers are FP-strict.
A top level class can be given package access that makes it visible within its package but not outside of the package. It can be given public access meaning that it is visible outside of its package.
Unlike some nested classes, a top-level class can not be given private or protected access and can not be declared static.

Dan Chisholm<br />SCJP 1.4<br /> <br /><a href="" target="_blank" rel="nofollow">Try my mock exam.</a>
Dan Chisholm
Ranch Hand

Joined: Jul 02, 2002
Posts: 1865
If you are looking for a mock exam that covers declarations and provides detailed explanations of the answers then please try my declarations exam.
Kathy Sierra
Cowgirl and Author

Joined: Oct 10, 2002
Posts: 1589
Very nice explanation Dan!

Co-Author of Head First Design Patterns
Just a Jini girl living in a J2EE world.
Dan Chisholm
Ranch Hand

Joined: Jul 02, 2002
Posts: 1865
Thank you Kathy.
I agree. Here's the link:
subject: Top Level Class
jQuery in Action, 3rd edition