CodeToConcept
About

java

java Tutorials

Introduction
Java Variables
Java Data Types
Java Type Casting
Java Operators
Java Input/Output
Java Class & Object
java Method
Java Constructor
Java this keyword
Java super keyword
Java Method Overloading and Overriding
Java Interface
Java Abstract Class
Java Memory Management
Design Patterns
JDBC (Database Connectivity)
Java IDEs

java Tutorials

Introduction
Java Variables
Java Data Types
Java Type Casting
Java Operators
Java Input/Output
Java Class & Object
java Method
Java Constructor
Java this keyword
Java super keyword
Java Method Overloading and Overriding
Java Interface
Java Abstract Class
Java Memory Management
Design Patterns
JDBC (Database Connectivity)
Java IDEs

Sample Question

Think it through, then check the tutorial.

CodeToConcept

Quickly learn through simple, structured, and practical coding tutorials. Build your confidence from step zero to real-world experience.

© 2026 CodeToConcept. All rights reserved.

Quick Links

AboutTutorials

Tutorials

JavaHTMLCSS

Support

Privacy PolicyTerms of ServiceContact
GitHubTwitterYouTube

Java Modifiers

Modifiers add rules to Java declarations. Some control where a class or member can be accessed. Others describe properties such as belonging to the class or preventing reassignment.

Why Do We Need This?

A score field may need to be private so changes go through a method. A shared constant can be static and final so it belongs to the class and cannot be assigned another value.

Main Ideas

ConceptWhat it means
Access modifierspublic, protected, and private control access
Package-private accessApplies to ordinary class members with no access modifier
staticMakes a field or method belong to the class
finalPrevents reassignment of a variable; has different rules for classes and methods
abstractDescribes a class that cannot be instantiated or a method without an implementation

Simple Working Example

Run this program on its own. All required imports and classes are included.

class Quiz {
    private int score = 8;
    public static final int MAX_SCORE = 10;
 
    public int getScore() {
        return score;
    }
}
 
public class HelloWorld {
    public static void main(String[] args) {
        Quiz quiz = new Quiz();
        System.out.println(quiz.getScore() + " out of " + Quiz.MAX_SCORE);
    }
}

Output

8 out of 10

The private score is read through getScore(). MAX_SCORE belongs to Quiz because it is static, and final prevents assigning a new value to it.

Topics in This Section

  • Java Access Modifiers
  • Java Non-Access Modifiers

Easy Way to Remember

Access modifiers answer where code may be used. Non-access modifiers add other rules. The default keyword is not a package-private access modifier.

See you in next page....??

← Java Method Overloading and OverridingJava Access Modifiers →
← Java Method Overloading and OverridingJava Access Modifiers →