Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Reg. Inner classes : Valiveru's exam

 
Angela Narain
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which of the following are true about inner classes
A.Inner classes can only be instantiated in its outer class
B.Inner classes can be protected or private
C.Anonymous inner class can be both an explicit subclass
and implements an interface.
D.Anonymous inner classes declare and instantiated at the
same place.
E.An inner class can be static only when it's outer class
is static.
F.An instance of an Anonymous inner class can only be
created in it's outer class
What are the correct answers ?
I assumed B, C, D
 
Gagan Indus
Ranch Hand
Posts: 346
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i guess only B & D are correct
A) Instance of Inner classes can be made , where they are accessible , using outer.new inner()
C)Anonymous class can either implement an interface ( in dat case , they be extending from Object class ) OR extend a class , but NOT BOTH
E) Inner class ( local or anonymous ) can be implicitly static , when its declared in static context ( like static initializer )
F) Instance of anonymous class can only be created at da place they r declared .

------------------
Gagan (/^_^\)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic