This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes standard terminology on inner class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "standard terminology on inner class" Watch "standard terminology on inner class" New topic

standard terminology on inner class

Aaron Anders
Ranch Hand

Joined: Dec 30, 2002
Posts: 39
version 1
  • JLS page 135 states that "A nested class is any class whose declaration occurs within the body of another class or interface", also on page 140, it says "An inner class is a nested class that is not explicitly or implicitly declared static"
  • TJPL 2nd ed. page 52 states that "Non-static nested classes are called inner classes"

  • version 2
  • Nutshell 3rd ed. page 117 states that "there are four other types of classes, loosely known as inner classes", including "Static member classes"
  • Marcus Green mock exam #2 Q44 states that "An inner class may be defined as static" (correct answer)

  • which version is "official"? also what should we answer if we encountered questions like this?
    William Brogden
    Author and all-around good cowpoke

    Joined: Mar 22, 2000
    Posts: 13037
    Yes, nomenclature about nested classes is frequently sloppy. When in doubt, go with the JLS of course. Any question on the test will surely state if the class in question is static.
    Kathy Sierra
    Cowgirl and Author

    Joined: Oct 10, 2002
    Posts: 1589
    Howdy --
    In this new 1.4 version of the exam, we tried to modify the language to change the use of "inner class" to "nested class" in all cases, static or not. But I'm not certain we were 100% successful on changing everything.
    But here's the breakdown of terminology you *might* see, and what it means on the exam:
    * Nested class
    -this could be either static or non-static
    * Inner class
    - this could *also* mean either static or non-static
    * Top-level nested class
    Definitely means STATIC nested/inner class
    * Non-static inner class or non-static nested class
    -speaks for itself
    * Static inner class or static nested class
    Definitenly means STATIC nested/inner class
    STATIC inner/nested class could be called any of the following:
    * Top-level nested class
    * static inner class
    * static nested class
    a NON-static inner/nested class could be called any of the following:
    * nested class
    * inner class
    * method-local inner class
    * anonymous inner class
    The only issue you might have is that you *might* see a question similar to the following:
    Which of these modifiers may be used on with an inner class?
    and so on...
    In this case, it would be appropriate to choose "static" as a correct answer. Some people have found this disturbing because they assume that the term "inner class" automatically means DEFINITELY NOT STATIC, but we're using the term "inner" in a broader sense -- in the old, original sense of the word.
    But as I said, I'm pretty sure we got rid of all of those anyway. Just know that you will NEVER be expected to recognize the difference between "inner" and "nested".
    Yes, you can count on me to make things even more confusing
    Jim Yingst

    Joined: Jan 30, 2000
    Posts: 18671
    * Top-level nested class
    Definitely means STATIC nested/inner class

    Just so people know, the term "top-level nested class" came from to poorly-named "Inner Class Specification" which has since been replaced by the JLS 2nd edition. The JLS2, which has now been out almost three years, no longer uses the term "top-level nested class" - instead it uses "static member class". The term "top-level" now refers only to classes which are not nested. A static member class is not considered top-level, nor is it an inner class.
    Of course, what you see on the exam may be different; follow Kathy's post for that. I'm just reporting what the spec says, as that's "official" answer. For what it's worth, when I took the 1.4 exam none of these terms appeared anywhere on the questions I saw. They just used code samples to show a class, and let me figure out what kind of class it was, and how it would behave. I wasn't expected to give the name - only to understand how it works.
    In the distant past (Java 1.1?), it was reported that the exam did contain a question that referred to a "static inner class" (which was never correct terminology, even in the Inner Classes Specification). But this seems to have been removed some time ago.

    "I'm not back." - Bill Harding, Twister
    I agree. Here's the link:
    subject: standard terminology on inner class
    It's not a secret anymore!