• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

inner classes

 
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
 
Ranch Hand
Posts: 413
  • 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
 
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...
 
You had your fun. Now it's time to go to jail. Thanks for your help tiny ad.
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic