• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

inner classes

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 477
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic