Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / May 2006

Tip: Looking for answers? Try searching our database.

What is the use of Protected modified when default works fine

Thread view: 
Suresh Reddi - 24 May 2006 01:08 GMT
Hi,

I have doubt regarding protected modifier.
as per definition, the visibility of "protected" and "default" are

Visible to the package and all subclasses (protected).
Visible to the package-the (unfortunate) default. No modifiers are
needed.

My doubt is when "default" field/method is visible to package, it might
also visible to sub-class as well. then why "protected" is required?

Or is it so that, one class can become sub-class of a super-class from
other package?

Thanks in advance.
Suresh
Adam Maass - 24 May 2006 02:54 GMT
> Hi,
>
[quoted text clipped - 10 lines]
> Or is it so that, one class can become sub-class of a super-class from
> other package?

"default" is visible to all classes in the same package, whether subclass of
the current class or not. "protected" is visible to all classes in the same
package, as well as subclasses in other packages.

-- Adam Maass
Suresh - 24 May 2006 18:12 GMT
Thanks Adam,
your explanation makes me more clear on this topic


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.