aspose file tools*
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 EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Private "class" ??" Watch "Private "class" ??" New topic

Private "class" ??

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
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?
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
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!
I agree. Here's the link:
subject: Private "class" ??
Similar Threads
Class modifiers
If static inner classes are top level classes then why does this compiles
Question on Classes
Default constructor
Interface Question - Can you answer it?