• 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
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

AccessModifiers and Access Specifiers

 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the difference between Access Specifiers and Access Modifiers.
Could you give me an examples on both.
What is going to happen when we declare a class with private and protected access specifiers.
 
author and iconoclast
Posts: 24203
44
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1) No difference, just two different terms for the same thing.
2) Assuming we're talking about top-level classes: it won't compile. Top-level classes can be public, or they can have no access modifier. They can't be private or protected.

Inner classes can have any one access specifier, but they can't use two at once (nor can any other class members.)
 
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Access Specifiers define the restriction level for visibility of a class/method/variable. (public, private, protected)

Access Modifiers define the behavior of a class/method/variable. They modify the way a class/method/variable can be used. (final, static, transient, volatile, synchronized etc.,)

You have to be sure which combination of these are valid for a class/method/variable so that your requirement is met in a compiler-legal way.
 
Master Rancher
Posts: 3899
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know this thread is ancient, but since someone recently quoted it here, I feel it needs a response:

Sravan Kumar wrote:Access Modifiers define the behavior of a class/method/variable. They modify the way a class/method/variable can be used. (final, static, transient, volatile, synchronized etc.,)


No, there is no way that final, static, transient, volatile or synchronized can be considered access modifiers. They are all modifiers, but they have nothing to do with access. Ernest Friedman-Hill was correct above (as usual): access modifiers and access specifiers are the same thing, and they do not include the other modifiers listed above.
 
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I know this post is much older. I was provided a link to this to see for same question. This question is on stackoverflow also. The similarities in answers I have seen is regional. I saw that only indian guyz are answering as access specifier and access modifier are two different words. But y? R they getting wrong printed books?

Thanks
Adeeb
 
Marshal
Posts: 72988
330
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

adeeb alexander wrote: . . . I saw that only indian guyz are answering as access specifier and access modifier are two different words. But y? R they getting wrong printed books?

Thanks
Adeeb

Probably, yes. A lot of them seem to use incorrect nomenclature.

And please read this.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic