aspose file tools*
The moose likes Beginning Java and the fly likes Question About Access Specifier Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Question About Access Specifier" Watch "Question About Access Specifier" New topic
Author

Question About Access Specifier

Seema Sehgal
Greenhorn

Joined: May 27, 2004
Posts: 2
Why we cannot declare Base Class to be protected or private?
Chengwei Lee
Ranch Hand

Joined: Apr 02, 2004
Posts: 884
Think about it, does it make any sense to make your main class private?


SCJP 1.4 * SCWCD 1.4 * SCBCD 1.3 * SCJA 1.0 * TOGAF 8
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Seema,

Welcome to JavaRanch!

We ain't got many rules 'round these parts, but we do got one. Please change your display name to comply with The JavaRanch Naming Policy.

Thanks Pardner! Hope to see you 'round the Ranch!


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Why we cannot declare Base Class to be protected or private?

Just in case the reasons weren't becoming clear...

If an outer class were private, then what use would it be since nobody outside the class could access it? It probably wouldn't be very much use since it wouldn't be usable.

If an outer class is declared with default/package access, then other classes in the same package have access to it, while those outside the package wouldn't have access.

If an outer class is declared with protected access, then who has access to it? Well, other classes in the same package would probably have access, but what about classes in a different package? Another classes outside the package couldn't subclass it since it's not accessible outside the package. So, protected would seem like a meaningless access modification.

At least, that's how I'd guess the language designers considered the issue.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question About Access Specifier