aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Classes declared as static? 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 "Classes declared as static?" Watch "Classes declared as static?" New topic
Author

Classes declared as static?

Sandra Bachan
Ranch Hand

Joined: Feb 18, 2010
Posts: 434
Came across a question in Enthuware:

Which of the following statements are true?

1. Package member classes can be declared static.
2. Classes declared as members of top-level classes can be declared static.
3. Local classes can be declared static.
4. Anonymous classes cannot be declared static.
5. No classes can be declared static.


I cannot understand the following explanation:

Only classes declared as members of top-level classes can be declared static. Such a member is a top-level nested class if it is declared static, otherwise it is a non-static inner class.
Package member classes, local classes(ie. classes declared in methods) and anonymous classes cannot be declared static.



Is there an example that demonstrates this? I haven't come across this in K&B book.

Marriage Made in Heaven
http://www.youtube.com/user/RohitWaliaWedsSonia
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3071
    
  33

The Inner classes chapter in K&B book explains this.


Mohamed Sanaulla | My Blog
Sandra Bachan
Ranch Hand

Joined: Feb 18, 2010
Posts: 434
mohamed sanaullah wrote:The Inner classes chapter in K&B book explains this.




Well, I guess I'll come across this when I skim the book this upcoming week!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Classes declared as static?