This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

nested classes

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is the following statement
1) true or
2) false?
"a nested top-level class cannot declassre any static variables, static methods, or static initializers."
can somebody decipher this for me?
 
paul wheaton
Trailboss
Pie
Posts: 21749
Firefox Browser IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can it be nested and top level at the same time?
Well, whatever craziness is happening there, I would have to say the method is false because inner classes can have static stuff too. (although I've never tried it, I'm pretty sure they can)
Anyone tried compiling this?
 
Tony Alicea
Desperado
Sheriff
Posts: 3226
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"How can it be nested and top level at the same time?"
I read that you have Peter van der Linden's Just Java 2? Could you check page 235, Table 9-1?
This nomenclature has driven more people than myself crazy before...!
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Heck, "top-level nested" is fine. It's when they talk about "static inner" classes that the arguments start.
Prasad-
A top-level nested class is Sun's official term for what is often called a static inner class (or static nested, which is better really), e.g.

As you can see, it can declare static methods and variables, as well as non-static (not shown).
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The reason I posted this question is that I got this question in one of the mock tests
Prasad
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic