Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Classes declared as static?

 
Sandra Bachan
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Mohamed Sanaulla
Saloon Keeper
Posts: 3159
33
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Inner classes chapter in K&B book explains this.

 
Sandra Bachan
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic