This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Why a regular class cannot be protected. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Why a regular class cannot be protected." Watch "Why a regular class cannot be protected." New topic
Author

Why a regular class cannot be protected.

Harikrishna Gorrepati
Ranch Hand

Joined: Sep 23, 2010
Posts: 422
Hi, Why a regular class cannot be protected.


OCPJP 6.0-81% | Preparing for OCWCD
http://www.certpal.com/blogs/cert-articles | http://sites.google.com/site/mostlyjava/scwcd |
Abimaran Kugathasan
Ranch Hand

Joined: Nov 04, 2009
Posts: 2066

Harikrishna Gorrepati wrote:Hi, Why a regular class cannot be protected.

You can use the same modifiers for inner classes that you use for other members of the outer class. For example, you can use the access specifiers — private, public, and protected — to restrict access to inner classes, just as you do to other class members.


|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
Harikrishna Gorrepati
Ranch Hand

Joined: Sep 23, 2010
Posts: 422
Hi Abimaran, I am not clear. I am referring basic helloworld class which cannot have protected access specifier. what is the reason.
Abimaran Kugathasan
Ranch Hand

Joined: Nov 04, 2009
Posts: 2066

Harikrishna Gorrepati wrote:Hi Abimaran, I am not clear. I am referring basic helloworld class which cannot have protected access specifier. what is the reason.

Please => TellTheDetails <=.
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9280
    
  17

What is the use of assigning protected access to a top level class?? What purpose would it serve??


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Harikrishna Gorrepati
Ranch Hand

Joined: Sep 23, 2010
Posts: 422
So that super(Parent) class can be accessed in different packages



Abimaran Kugathasan
Ranch Hand

Joined: Nov 04, 2009
Posts: 2066

Oh My Bad, I confused with the regular and the regular inner class. Sorry Harikrishna Gorrepati, I confused you.
Abimaran Kugathasan
Ranch Hand

Joined: Nov 04, 2009
Posts: 2066

For this purpose, you can use/make the Parent class' Constructor as protected!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why a regular class cannot be protected.
 
Similar Threads
protected class?
protected class ???
Why a basic regular class cannot be private and protected
protected class
Question on protected access modifier