Hi Friends this is Question from JQplus
Question ID :953582884020
Which of these statements are true?
Non static inner class cannot have static members
Objects of top level nested classes can be created without creating instances of outer class
Members variables in any nested class cannot be declared final
Anonymous classes cannot have constructors
Anonymous classes cannot be static
Jqplus Answers: 2, 4, 5
My Answers: 1, 2 & 4
What I think
1. Non Static Inner Class Cannot declare Static methods, Members of enclosing class are not inherited and hence they are not members of Nonstatic innerClass, they are just accessible from there.
2.Objects of Toplevel nested class can be created without creating instances of outer class
This is true.
3.Member variables in any nested class cannot be decalred final
False
4. Anonymous Class cannot have Contructors
True, That's one reason of using instance initializers.
5. Anonyous class cannot be static.
False, They can be if they are defined in a static context(Eg Static Initializer)
So Please ppl in ranch do shed light on it.
Thanks in advance
Ashish
(
Sometimes the answers in the
test, really shake u up(Ur Confidence), but that's the Time javaranch come to the rescue and makes us really feel comfortable before the exam.)