Jane Griscti
SCJP, Co-author Mike Meyers' Java 2 Certification Passport
Testing objectives for the Programmer for Java 2 Platform state:
(Overloading, Overriding, Runtime Type, and Object Orientation)
"Write code to construct instances of any concrete class including normal top level classes, inner classes, static inner classes, and anonymous inner classes".
Now according to the JLS (8.1.2 Inner Classes and Enclosing Instances)
"An inner class is a nested class that is not explicitly or implicitly declared static."
Also, it states under (8.5.2 Static Member Type Declarations)
"The static keyword may modify the declaration of a member type C within the body of a non-inner class T. Its effect is to declare that C is not an inner class."
There appears to be a stark contradiction between the JLS and the testing objectives for the Programmer for Java 2 Platform, which states the existence of Static Inner Classes.
According to my interpretation of the JLS, this entity that is referred to as a "Static Inner Class" should actually be called a Static Member Class.
Now my problem is this. If you get a question in the exam that poses the following: -"Can an Inner Class be static?" According to JLS (8.1.2 Inner Classes and Enclosing Instances) the answer is no. (I have seen many sources that state the opposite!! What answer do I need to give to collect the marks?) Nested Member Classes however can be static, coderanch, protected, private, abstract and final.
Furthermore, many sources state that nested top-level classes are static inner classes, but again the JLS, contradicts this.
"A nested class is any class whose declaration occurs within the body of another class or interface. A top level class is a class that is not a nested class."
Also could somebody confirm or correct the following hierarchy:-
* Top Level Classes
* Nested Classes
********* Member Classes
**************** Static Member Classes
**************** Inner Classes
************************ Non-static member classes
************************ Local Classes
************************ Anonymous Classes
Rosie
Jane Griscti
SCJP, Co-author Mike Meyers' Java 2 Certification Passport
SCJP2. Please Indent your code using UBB Code
I guarantee that you will not see that question on the SCJP2 exam.Originally posted by Rosie Nelson:
Now my problem is this. If you get a question in the exam that poses the following: -"Can an Inner Class be static?"
Also could somebody confirm or correct the following hierarchy:-
* Top Level Classes
* Nested Classes
********* Member Classes
**************** Static Member Classes
**************** Inner Classes
************************ Non-static member classes
************************ Local Classes
************************ Anonymous Classes
JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Consider Paul's rocket mass heater. |