http://www.jchq.net/mockexams/exam2.htm#Answer%2044)
Question 44)
Which of the following statements are true
1) An inner class may be defined as static
2) There are NO circumstances where an inner class may be defined as private
3) A programmer may only provide one constructor for an anonymous class
4) An inner class may extend another class
Ans By Marcus Green---
1) An inner class may be defined as static
4) An inner class may extend another class
A static inner class is also sometimes known as a top level nested class. There is some debate if such a class should be called an inner class. I tend to think it should be on the basis that it is created inside the opening braces of another class. How could a programmer provide a constructor for an anonymous class?. Remember a constructor is a method with no return type and the same name as the class. Inner classes may be defined as private
According to JLS , I had marked option "1" as false and I thought for the exam point of view "Inner classes cannot be static, because this is what JLS says"
But while going thru Maha Anna's Traps to be aware of in any
SCJP test I found the following quote from Jim Yingst
However, the exam does apparently consider static member classes to be inner classes, even though this is clearly contradicted by the Nested Classes Specification and the JLS2. They don't make a big deal about it - they just call them "static inner classes". So, for the exam, pretend they're inner classes, and remember that in the real world, they aren't.
I think I also had a discuusion on this topic with Dan earlier that JLS is the ultimate for exam point of view..!!!
Then why this contradiction by Jim Yingst ?
Shud I answer option 1 as true of false in the exam ??