- In old language like C++ public, private, protected, default are considered as Access Specifiers . Except this remaining ( like static ) are considered as Access Modifiers.
- But in Java there is no terminology like specifiers, all are by default considered as modifiers only.
public
synchronized
private
abstract
protected
native
default
strictfp(1.2v)
final
transient
static
volatile
- All this 12 are refer as access modifiers only but not specifiers.
Proof for this:
- Observe the below class
package interviewdev.blogspot.in; /** * @author amol * * access modifiers allowed to AccessModifierTest(outer class) are : * 1. public * 2. default * 3. abstract * 4. final * 5. strictfp(1.2v) */ class AccessModifierTest { //TODO code }
- If different modifier specified other than mentioned in comment, following compile time error will be thrown.
- Illegal modifier for the class AccessModifierTest; only public, abstract & final are permitted AccessModifierTest.java /TestProj/src/interviewdev/blogspot/in line 13 Java Problem