Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
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 Android Security Essentials Live Lessons this week in the Android 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

basic question on access modifiers and levels

Pran Pal

Joined: Mar 02, 2006
Posts: 10

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?

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
I agree. Here's the link:
subject: basic question on access modifiers and levels
Similar Threads
Question on Access Modifiers
static class protected access
default access sepecifiers
remembering access modifiers