permaculture playing cards*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes nested classes 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 "nested classes" Watch "nested classes" New topic
Author

nested classes

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
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

Joined: Dec 14, 1998
Posts: 20542
    ∞

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?

permaculture Wood Burning Stoves 2.0 - 4-DVD set
Tony Alicea
Desperado
Sheriff

Joined: Jan 30, 2000
Posts: 3222
    
    5
"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...!


Tony Alicea
Senior Java Web Application Developer, SCPJ2, SCWCD
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
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).

"I'm not back." - Bill Harding, Twister
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
The reason I posted this question is that I got this question in one of the mock tests
Prasad
 
 
subject: nested classes