wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Protected  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 "Protected  Access Specifier" Watch "Protected  Access Specifier" New topic
Author

Protected Access Specifier

kedar parundekar
Ranch Hand

Joined: May 10, 2006
Posts: 40
Why "Protected" access specifier is not allowed to Top Level classes?
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 13875
    
  10

Look at it this way: Suppose you could make a top level class "protected". What would that mean? Why would that be useful?


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
Originally posted by Jesper Young:
Look at it this way: Suppose you could make a top level class "protected". What would that mean?


It would mean your code is protected for more secure programming, right?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36507
    
  16
What would that mean?

I have never tried it, but I think it would mean that there is no access to subclasses outside the superclass' package. Anybody wish to try it? I don't.

CR
kedar parundekar
Ranch Hand

Joined: May 10, 2006
Posts: 40
Originally posted by Jesper Young:
Look at it this way: Suppose you could make a top level class "protected". What would that mean? Why would that be useful?


I agree with you answer.
But my another query is -> If I want to use this protected class in same package only. why it is not useful?
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
Originally posted by kedar parundekar:

If I want to use this protected class in same package only. why it is not useful?


In your hypothetical change to Java, what would be the difference between these two top-level classes?

[ May 17, 2006: Message edited by: Jeff Albertson ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Protected Access Specifier
 
Similar Threads
A small doubt
doubt in protected access specifier
Protected Access Specifier
java.lang.object
Protected Class