• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Access Controls and access modifiers

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Referring book SCJP 6 by K&B, on page 12 it has mentioned that "4 access controls but only 3 access modifiers, the 4th control level called default or package access. "

So my understanding is

1. Access control is public, private, protected, "default"
2. Access modifiers public, private, protected
3. Non-access modifiers strictfp, final and abstract

Am I correct ?

thanks & regards
parag


 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Depends on which level you are using these modifiers. Methods can be synchronized, native, static. The outer classes can only be public or default. The top-level inner classes can be static.
 
Ranch Hand
Posts: 820
IntelliJ IDE VI Editor Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Parag Patankar wrote:
Referring book SCJP 6 by K&B, on page 12 it has mentioned that "4 access controls but only 3 access modifiers, the 4th control level called default or package access. "

So my understanding is

1. Access control is public, private, protected, "default"
2. Access modifiers public, private, protected
3. Non-access modifiers strictfp, final and abstract

Am I correct ?



If you are talking about methods or inner classes, You are correct for 1 and 2

for methods, the non-access modifiers are
strictfp
final
static
abstract
native
synchronized

Check out this chart of all the modifiers and where they can be used:
http://www.uni-bonn.de/~manfear/javamodifiers.php
 
Parag Patankar
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Rajeev and Tim.

Tim, chart is really giving very clear picture.

regards
parag
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic