Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

inner classes

 
prakash pai
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is true about inner classes?
A) inner class can only be instantiated in its outer class.
B) Inner class be protected or private
C) Anonymous inner class can be both an explicit subclass and implements an interface
D) Anonymous inner class declare and instantiated at same place.
E) An instance of anonymous inner class can only be created in its outer class.
I marked D and E. But mock test gives B and D.
Could some one please explain why B is correct and not E.
Thanks in advance
 
Gaurav Chikara
Ranch Hand
Posts: 412
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is clearly mentioned in JLS that private ,protected,static access modifiers are available for Inner class only
thus B is correct
Regarding e
Annonymous class are instaniated at the same time when they
are created and language of e says that it is the only way to create anonymous class thats why it is incorrect
hope it helps
 
Marcela Blei
Ranch Hand
Posts: 477
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Gaurav Chikara:
Regarding e
Annonymous class are instaniated at the same time when they
are created and language of e says that it is the only way to create anonymous class thats why it is incorrect
hope it helps

I think e) is correct exactly beware that Annonymous classes are instaniated at the same time when they are created and they are created in an Outer class so...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic