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.
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.)
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.
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?