- 1 Final Non Access Modifiers
- 2 Abstract Non Access Modifier
- 3 Synchronized Non Access Modifier
- 4 Native Non Access Modifier
- 5 Strictfp Non Access Modifier
In this article you will learn about Non Access Modifiers in Java. Below are the Non Access Modifiers available in Java.
Final Non Access Modifiers
Final modifiers are applicable to :
Final Class :
A Class when set to final cannot be extended by any other Class.
Example: A String Class in java.lang package
Final Method :
A Method when set to final cannot be overridden by any subclass.
Final Variable :
When a variable is set to final, its value cannot be changed. Final variables are like constants.
Example : public static final int i = 10;
Abstract Non Access Modifier
Abstract modifiers are applicable to:
An abstract Class can have abstract Methods. A Class can also be an abstract class without having any abstract Methods in it. If a Class has an abstract Method , the Class becomes an abstract Class.
Abstract Method :
Abstract Methods are those Methods which does not have a body but only a signature.
Example : public abstract void method();
Synchronized Non Access Modifier
Synchronized modifiers are applicable to
Synchronized Methods can be accessed by only one thread at a time.
Native Non Access Modifier
Native modifiers are applicable to
Naive Methods indicate that the method is implemented on a platform dependent code.
Strictfp Non Access Modifier
Strictfp modifiers are applicable to
Strictfp Class / Method
Strictfp non access modifier forces floating point or floating point operation to adhere to IEEE 754 standard.
Note*: Strictfp non access modifier cannot be applied on a variable.
- Non Access Modifiers available in Java are Static, final, abstract, synchronized & Volatile
- Static keyword can be applied to Variables & Methods.
- Static Variable are those variables which are not associated to any instance but it is associated to class means all instances will access the same single copy of variable.
- Local variables can not be declared as Static.
- Static keyword can also be applied to Methods. They will work for all the instances and they will not be dependent on instances created.
- Final modifier can be applied to method and variables.
- Final is the only modifier which will be available to local variable.
- Once declared as final value of the variable can not be changed.
- Final variable don’t get default value opposed to instance variable coz value can’t be changed once assigned.
- Final method can not be overriden.