• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Classes declared as static?

 
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 3225
34
IntelliJ IDE Oracle Spring Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic