Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

basic question on access modifiers and levels

Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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?

Ranch Hand
Posts: 2410
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The default access level does not have an access modifier.
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
It's just like a fortune cookie, but instead of a cookie, it's pie. And we'll call it ... tiny ad:
Thread Boost feature
    Bookmark Topic Watch Topic
  • New Topic