This week's book giveaway is in the Agile forum.
We're giving away four copies of Head First Agile and have Andrew Stellman & Jennifer Greene on-line!
See this thread for details.
Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Classes declared as static?  RSS feed

 
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
Bartender
Posts: 3181
34
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!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!