About Question com.enthuware.ets.scjp.v6.2.654 :
Moderators: Site Manager, fjwalraven
-
- Posts: 8
- Joined: Tue Oct 25, 2011 10:46 am
- Contact:
About Question com.enthuware.ets.scjp.v6.2.654 :
Option "Objects of top level nested classes can be created without creating instances of their Outer classes." seems to be ambigous. Please consider changing to "Objects of top level static nested classes can be created without creating instances of their Outer classes." Without this qualification I don't think the statement is correct as it is not true for all objects of top level nested classes.
-
- Site Admin
- Posts: 10062
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question com.enthuware.ets.scjp.v6.2.654 :
Hello,
You are right. This and a few other questions were based on an outdated terminology. Initially, when Java came out with inner classes, static nested classes were also considered top level classes. To quote, Sun's "Inner Class" specification:
HTH,
Paul.
You are right. This and a few other questions were based on an outdated terminology. Initially, when Java came out with inner classes, static nested classes were also considered top level classes. To quote, Sun's "Inner Class" specification:
Later on, they changed the terminology as follows:In addition, the programmer can define one top-level class as a static member of another top-level class. Unlike an inner class, a top-level class cannot directly use the instance variables of any other class. The ability to nest classes in this way allows any top-level class to provide a package-like organization for a logically related group of secondary top-level classes.
Inner classes and nested top-level classes are implemented by the compiler, and do not require any changes to the Java Virtual Machine. They do not break source or binary compatibility with existing Java programs.
Sorry for the confusion. This has now been updated.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. An inner class is a nested class that is not explicitly or implicitly declared static. A class defined inside an interface is implicitly static.
HTH,
Paul.
If you like our products and services, please help us by posting your review here.
Who is online
Users browsing this forum: No registered users and 70 guests