File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Doubt on Modifiers 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 "Doubt on Modifiers" Watch "Doubt on Modifiers" New topic
Author

Doubt on Modifiers

balajee annamalai
Ranch Hand

Joined: May 09, 2007
Posts: 31
I know that we cannot declare a class as both abstract and final this is beacuse both modifiers are opposite to each other.But i dont understand why cant we declare a class as private or protected is there any reason behind this?
Jelle Klap
Bartender

Joined: Mar 10, 2008
Posts: 1752
    
    7

You can, in fact, use any visibility modifier when declaring a class, be it package default, private, protected or public.


Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
Nadeem Khan
Ranch Hand

Joined: Nov 27, 2007
Posts: 108
Hey Jelle,
Can you please give an example where we can declare a class as "private".Because it is not allowed with class-declaration statement as far as i know.


<i>If there were no Exceptions (not Errors!), Life would have kinda sucked!!</i>
Jelle Klap
Bartender

Joined: Mar 10, 2008
Posts: 1752
    
    7

Only in the case of an inner class definition.
I'm afraid my previous statement was lacking nuance.

Nadeem Khan
Ranch Hand

Joined: Nov 27, 2007
Posts: 108
Ok that explains
 
Don't get me started about those stupid light bulbs.
 
subject: Doubt on Modifiers
 
Similar Threads
can we use non access modifiers combinely for members
Access Modifiers
why we cann't make a class private and protected
classes syntax
AccessModifiers and Access Specifiers