• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Inner Classes

 
amit sanghai
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I'm sorry . The 2nd question is:

Is member inner class always non-static ? Can it contain static members?
 
amit sanghai
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I'm sorry . The 2nd question is:

Is member inner class always non-static ? Can it contain static members?
 
Adrian Yan
Ranch Hand
Posts: 688
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic