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
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
SCJP,SCWCD,SCBCD<br />If Opportunity doesn't knock then build the door
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...
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.