wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Inner 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 "Inner Classes" Watch "Inner Classes" New topic
Author

Inner Classes

amit sanghai
Ranch Hand

Joined: Dec 05, 2000
Posts: 231

Hi everybody,
I have 4 questions:
Q1) Is nested top-level class always static? Can it access private fields of the enclosing class ?
Q2) Is member inner class always non-static? Can it contain non-static members?
Q3) Can member inner classes access stayic members of the enclosing class?
Q4) Can Anonymous inner classes extend any other class or implement an interface in its declaration?

amit sanghai
Ranch Hand

Joined: Dec 05, 2000
Posts: 231

I'm sorry . The 2nd question is:

Is member inner class always non-static ? Can it contain static members?
amit sanghai
Ranch Hand

Joined: Dec 05, 2000
Posts: 231

I'm sorry . The 2nd question is:

Is member inner class always non-static ? Can it contain static members?
Adrian Yan
Ranch Hand

Joined: Oct 02, 2000
Posts: 688
Originally posted by amit sanghai:

Hi everybody,
I have 4 questions:
Q1) Is nested top-level class always static? Can it access private fields of the enclosing class ?
Q2) Is member inner class always non-static? Can it contain non-static members?
Q3) Can member inner classes access stayic members of the enclosing class?
Q4) Can Anonymous inner classes extend any other class or implement an interface in its declaration?

-----------------------------------------------------------------
(1) I believe is no, if the top-level nested class is static, it will be just a regular top-level class.
(2) No, it doesn't have to be always non-static, it could be static.
 
jQuery in Action, 2nd edition
 
subject: Inner Classes