wood burning stoves 2.0*
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

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Protected Class?" Watch "Protected Class?" New topic

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
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?
Similar Threads
private and protected class - why not?
Question on protected access modifier
protected class
WA #1.....word association
protected member