GeeCON Prague 2014*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Top-Level class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Top-Level class" Watch "Top-Level class" New topic
Author

Top-Level class

Aarti Joshi
Greenhorn

Joined: Mar 31, 2003
Posts: 24
1) What is a top level class ? Can top level class be declared protected/private ?
--cheers
Aarti
Jessica Sant
Sheriff

Joined: Oct 17, 2001
Posts: 4313

Top Level class is any normal Java class, it can only be declared public or default (aka package).
like this:


- Jess
Blog:KnitClimbJava | Twitter: jsant | Ravelry: wingedsheep
Marlene Miller
Ranch Hand

Joined: Mar 05, 2003
Posts: 1391
Definition: A nested class is any class whose declaration occurs within the body of another class or interface.
Definition: A top level class is a class that is not a nested class.
Kathy Sierra
Cowgirl and Author
Ranch Hand

Joined: Oct 10, 2002
Posts: 1572
Howdy -- just wanted to add that there *is* some confusion (some of which I am responsible for) about the terminology because the JLS and Gosling's "The Java Programming Language" conflict. Gosling mentions that a static nested class is also known as a "Top Level Nested Class", but as Marlene pointed out , the spec clearly says that in order to be a Top Level class the class must NOT be nested. So, two documents Gosling has authored conflict with each another.
That's one of the few little 'issues' we have at Sun, because we're allowed to use just about anything Gosling says for the exam, as opposed to JUST the JLS, even though 90% of the exam wording now reflects the specification. The SCJP is also supposed to be about certifying working programmers, so we try to strike a balance between formal specification language and 'common use', as long as 'common use' isn't completely wrong or misleading. Well, in this case, many of us at Sun have been using the phrase "top level nested class" long enough ot have it burned into our heads. I'm in the process of removing it from mine right now. Ouch!
It used to be worse... the SCJP used to use the phrase "static inner class". Yikes! That was *never* correct, but in casual language, that's how we often talked about it.
I'm trying to work out if there are any other issues like that -- where there's a conflict between the spec and other Sun documents that might be used when we build the exam. I haven't found any that matter. And in fact, even this "top-level/static/nested" terminology won't hurt you on the exam. As long as you can identify in code exactly how they work, you won't be tripped up by what they're called.
Cheers!
Kathy
Marlene Miller
Ranch Hand

Joined: Mar 05, 2003
Posts: 1391
Kathy, thank you for sharing in detail your insider's view.
Marlene Miller
Ranch Hand

Joined: Mar 05, 2003
Posts: 1391
I have noticed in books and in forum discussions, some people use the word "visible" when they mean "accessible". The JLS has two definitions, one for accessible, another for visible.
Marlene Miller
Ranch Hand

Joined: Mar 05, 2003
Posts: 1391
Kathy, if the exams use definitions different from the JLS for top-level, nested, inner and static classes, I request that the terms and their meanings be published with the Objectives.
 
GeeCON Prague 2014
 
subject: Top-Level class