Non Access Modifiers

Non Access Modifiers

Here in this article you will learn about Non Access Modifiers. Below mentioned are the Non Access Modifiers available in Java.

  1. Final
  2. Abstract
  3. Static
  4. Strictfp
  5. Native
  6. Synchronized
  7. Transient

Final Non Access Modifiers
Final modifiers are applicable to :

  1. Class
  2. Method
  3. Instance Variable
  4. Local Variable
  5. Method arguments

Final Class :

A class when set to final cannot be extended by any other class.
Example:  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

Keyword: abstract
Abstract modifiers are applicable to:

  1. Class
  2. Method

Abstract Class:
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

  1. Method

Synchronized Method
Synchronized methods can be accessed by only one thread at a time.

Native Non Access Modifier
Native modifiers are applicable to

  1. Method

Native Method
Naive method indicates that a method is implemented on a platform dependent code.

Strictfp Non Access Modifier
Strictfp modifiers are applicable to

  1. Class
  2. Method

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.