aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Protected 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 "Protected Class?" Watch "Protected Class?" New topic
Author

Protected Class?

Charlie Swanson
Ranch Hand

Joined: Jan 29, 2001
Posts: 213
In general, why can't we declare a protected class (that is not including inner classes)?
Jane Griscti
Ranch Hand

Joined: Aug 30, 2000
Posts: 3141
Hi Charlie,
A 'protected' class can only be accessed by other classes within the same package or by any subclass. These conditions, for a top-level class, can all be met using the existing top-level class modifiers: 'abstract' and package (no modifier); which makes 'protected' redundant as a top-level modifier.

Hope that helps.

------------------
Jane Griscti
Sun Certified Programmer for the Java� 2 Platform


Jane Griscti
SCJP, Co-author Mike Meyers' Java 2 Certification Passport
Charlie Swanson
Ranch Hand

Joined: Jan 29, 2001
Posts: 213
Jane,
Thank you for the answer. Could you give a short sample of how to declare it with abstract and package?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Protected Class?