jQuery in Action, 2nd edition*
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Inner Classes
 
Similar Threads
Roundup #232
What's the difference?
Inner classes; when should they be static vs. instance?
Inner Classes
Static Inner Class Question