This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Private Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Private "class" ??" Watch "Private "class" ??" New topic
Author

Private "class" ??

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
On the Marcus Green exam #2, question 57, he asks if the following is true:
"Under no circumstances can a class be defined with the private modifier"
His answer is that the above statement is false. Now, I know that top-level classes can't be private or protected, so that's not my question. What I am confused about is this: when you see the word "class" (without mention of inner, nested, or anonymous), does that always mean top-level classes, only?? I'm taking the exam tomorrow, so I worry about such things.
chetan nain
Ranch Hand

Joined: Jun 21, 2000
Posts: 159
Dab,
no, i think mention of "class" does not guarantee it to be a top level class. for example, there may be a case of subclassing a class with "default" access. in this case, compiler would require us to declare the extending class to be either "protected" or "private". did i get you correctly?
HTH
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
HTH,
I was meaning top-level versus nested, inner, or anonymous; I wasn't meaning superclass versus subclasses.
A top-level (i.e., not an inner...) can only have default or public access. But inner and nested classes can be have public, protected, default, or private access.
I'll just take the lone word "class" in context the best that I an on the exam!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Private "class" ??
 
Similar Threads
Class modifiers
If static inner classes are top level classes then why does this compiles
Interface Question - Can you answer it?
Default constructor
Question on Classes