When i was taking a mock exam there was a question as to Which of the following modifiers are applicable to top level class public private static strictfp
can any one please tell me the correct answer i selected public but the answer says public and strictfp...the top level class can have default or public access modifier only right...can strictfp be applied to the top level class... sorry for troubling you with a simple question as im new to java and have just started to prepare for scjp
What happens when you compile a top level class with a modifier of private or static? Did you try that? If so, what messages did the compiler print, if any? Did the messages mean anything to you? It is absolutely essential that you try things out - learning Java programming is not only a theoretical process. There is a very important practical part that has to be learnt. [ January 21, 2007: Message edited by: Barry Gaunt ]
[Paul Anil]: Remember that a static nested class is also considered a Top Level class.
You're using ancient terminology. Yes, Sun did once invent the horrible, evil term "top-level nested class" but they got rid of it long ago. (JLS 2nd edition was released in 2000.) Bringing it up now just confuses people. In modern usage (since 2000), classes are either top-level or nested, never both.
[Paul Anil]: The term "Top Level class" is now kind of deprecated.
Not at all. The term now means exactly what anyone would expect it to mean, if they had never heard of Sun's silly "top-level nested class" notion (which should be excised from memory like a bad dream). A top level class is simply a class that's not nested.
Fortunately, the SCJP exam does not care whether people know this terminology or not.
Terminology: Nested classes are divided into two categories: static and non-static. Nested classes that are declared static are simply called static nested classes. Non-static nested classes are called inner classes.
Regarding static nested class -
Note: A static nested class interacts with the instance members of its outer class (and other classes) just like any other top-level class. In effect, a static nested class is behaviorally a top-level class that has been nested in another top-level class for packaging convenience.