Loading...

Non-Access Modifiers

These modifiers control inheritance, polymorphism, and memory management. Unlike access modifiers (which control visibility), these define how a class, method, or variable behaves.

Final

Represents a constant. Once defined, it cannot be changed.


  • Variable: Value cannot be changed (Constant).
  • Method: Cannot be overridden.
  • Class: Cannot be inherited (extended).

Static

Belongs to the class, not the instance. Shared across all objects.


  • Shared memory allocation (efficient).
  • Can be accessed without creating an object.
  • Cannot be applied to constructors.

Abstract

Declared without implementation. Must be implemented by subclasses.


  • Abstract Class: Cannot be instantiated.
  • Abstract Method: Has no body/logic.
  • Can contain both abstract and concrete methods.

Synchronized

Used in multi-threading to prevent thread interference.


  • Only one thread can access the block/method at a time.
  • Applies to methods and code blocks.
  • Ensures thread safety.

Advanced Modifiers

Native

Method implemented in another language (C/C++). Acts as a bridge to system libraries.

Volatile

Value is always read from main memory, not thread cache. Used in multi-threading.

Transient

Variables skipped during Serialization. Value is not saved/persisted.

Strictfp

Ensures floating-point (decimal) calculations are identical on all platforms.

Quick Reference Guide

Modifier Class Method Variable
Final
Static
Abstract
Synchronized
Transient