This week's giveaway is in the Groovy forum.
We're giving away four copies of Groovy Fundamentals video training course and have Ken Kousen on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes basic question on access modifiers and levels Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Groovy Fundamentals video training course this week in the Groovy forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "basic question on access modifiers and levels" Watch "basic question on access modifiers and levels" New topic
Author

basic question on access modifiers and levels

Pran Pal
Greenhorn

Joined: Mar 02, 2006
Posts: 10
Hi,

In the K&B 1.5 book, on page 68 (2 min drill), they wrote:
There are three access modifiers: public, protected, and private.
There are four access levels: public, protected, default, and private.


I'm a bit confused, Initially, I taught that both (modifier and level) were the same thing. But it doesn't looks like it.

What is the difference between an access modifier and access level?

thanks.
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
The default access level does not have an access modifier.
Jay Ashar
Ranch Hand

Joined: Oct 13, 2002
Posts: 208
What would you do if you want your class to be accessed only in package in which that class resides? You would not declare that class public and just declare the class without any keyword, which is default access.
So although your class does not have a keyword it still have an access-level.


SCJP 1.4<br />SCWCD 1.3
 
Consider Paul's rocket mass heater.
 
subject: basic question on access modifiers and levels