File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Q from javacertificate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Q from javacertificate" Watch "Q from javacertificate" New topic
Author

Q from javacertificate

Alton Hernandez
Ranch Hand

Joined: May 30, 2003
Posts: 443
This statement is marked true in their mock exam:

An instance of a top level nested class can be created without an instance of its enclosing class.

I think what they are referring to here is the static nested class. But the problem is that the term top level nested class does not exists in the JLS. There is a term top level class but it refers to any class that is not nested.
Any comments?
Anupreet Arora
Ranch Hand

Joined: Jun 17, 2003
Posts: 81
Exactly Alton! The term "top level nested class" refers to a static inner class, and the book on Java Certification by Khalid Moghul also uses the same to explain the concept of different types of nested/inner classes.
If I may quote from the book

A top level nested class or interface is similar to a top level or interface, but it is defined as a static member of an enclosing top level class or interface (Section 7.2)

The term is used because the behaviour of static inner classes is hardly any different from the normal top level classes.
Alton Hernandez
Ranch Hand

Joined: May 30, 2003
Posts: 443
Hi Anupreet,
Thank you for your reply.
I guess the main issue is that the term "top level nested class" does not exists in the JLS. They should not be using terminologies from one particular book because different authors may use different terminologies.
[ August 19, 2003: Message edited by: Alton Hernandez ]
Anupreet Arora
Ranch Hand

Joined: Jun 17, 2003
Posts: 81
Yes, U r right Fren!
In the JLS, second line of the chapter 8 is
"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".

So if "a top level class is a class that is not a nested class" then term "top level nested class" is a kind of oxymoron!!
Maybe it is used more to relate to the behaviour of a specific type of nested classes, than as a technically correct reference. So clearly, such usage in exams, mock or real, should be checked.
Regards,
Anupreet
Marlene Miller
Ranch Hand

Joined: Mar 05, 2003
Posts: 1391
I wonder if the term top-level nested was used in the first edition of the JLS.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Q from javacertificate
 
Similar Threads
question regarding modifiers applicable to top level class
INNER CLASS - Is it an error / JLS
Top level nested classes?
Why do we need static nested class?
top level nested interfaces