aspose file tools*
The moose likes Beginning Java 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 Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Protected class" Watch "Protected class" New topic
Author

Protected class

Philip Pomario
Ranch Hand

Joined: Oct 03, 2003
Posts: 113
Is there such thing as a class with the protected access modifier? I mean, can a class be defined visible only to its peers in the same package and subclasses of the outer-package-world? What are the modifiers that ca be applied to classes?

Any considerations are much welcome.
ramprasad madathil
Ranch Hand

Joined: Jan 24, 2005
Posts: 489

>Is there such thing as a class with the protected access modifier?
Well yes, inner classes can be protected. They could be private and static too (all these modifiers cannot be applied to Outer level classes)

>I mean, can a class be defined visible only to its peers in the same package and subclasses of the outer-package-world? What are the modifiers that ca be applied to classes?
High level classes/Outer classes/ie non-inner classes have only 2 modifiers - public or no modifier (public class X or class X). public classes are visible everywhere and the no-modifier one is visible only inside the pkg (to all sub-classes and non-sub-classes in the pkg).

Tx,
ram.
Yasith Vidanaarachchi
Greenhorn

Joined: Sep 18, 2004
Posts: 10
Hi,
Top level classes can only be public and friendly, but there can be only one public class per one source file.these are the access modifiers that can be applied to a classes(Top level).

Yasith Vidanaarachchi
---------------------
SCJP 1.4
[ January 28, 2005: Message edited by: Yasith Vidanaarachchi ]
Philip Pomario
Ranch Hand

Joined: Oct 03, 2003
Posts: 113
Thanks, guys!
Philip Pomario
Ranch Hand

Joined: Oct 03, 2003
Posts: 113
I just passed the SCJP1.4 exam and wanted to post this appreciation note to thank everyone who helped me understand Java a little better. Without your help this personal achievement wouldn't be possible.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Protected class