Originally posted by Paul Salerno:
Which statement is true about an inner class?
A. It must be anonymous
B. It can not implement an interface
C. It is only accessible in the enclosing class
D. It can only be instantiated in the enclosing class
E. It can access any final variables in any enclosing scope.
Their answer: E
My answer: C and E
C- because you need:
OuterClass.InnerClass x = new OuterClass().new InnerClass()
Whos right?
The option C says
C. It is only accessible in the enclosing class They can be accessed outside of the enclosing class too. Yes you need an Outer Class instance to INSTANTIATE an Inner Class instance(not true for static inner classes), but that instance can invoke methods of Inner class from Other classes too.
So C is not right!!!
Amish