Saturday, December 13, 2025
HomeLanguagesJavaModifiers classModifiers() method in Java with Examples

Modifiers classModifiers() method in Java with Examples

The classModifiers() method of java.lang.reflect.Modifier class is used to get an integer value together with the modifiers of source language that can be applied to a class.

Syntax:

public static boolean classModifiers()

Parameters: This method accepts nothing.

Return: This method returns an int value OR-ing together the source language modifiers that can be applied to a class.

Below programs illustrate classModifiers() method:
Program 1:




// Java program to illustrate
// classModifiers() method
  
import java.lang.reflect.*;
  
public class GFG {
  
    public static void main(String[] args)
        throws NoSuchFieldException,
               SecurityException
    {
  
        // get Modifier using classModifiers()
        int result = Modifier.classModifiers();
  
        System.out.println(
            "Modifiers: "
            + Modifier.toString(result));
    }
}


Output:

Modifiers: public protected private abstract static final strictfp

Program 2:




// Java program to illustrate classModifiers()
  
import java.lang.reflect.*;
  
public class GFG {
  
    public static void main(String[] args)
        throws NoSuchFieldException,
               SecurityException
    {
  
        // get Modifier using classModifiers()
        int result = Modifier.classModifiers();
  
        System.out.println("Int Value: "
                           + result);
    }
}


Output:

Int Value: 3103

References: https://docs.oracle.com/javase/10/docs/api/java/lang/reflect/Modifier.html#classModifiers()

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

1 COMMENT

Most Popular

Dominic
32447 POSTS0 COMMENTS
Milvus
105 POSTS0 COMMENTS
Nango Kala
6816 POSTS0 COMMENTS
Nicole Veronica
11953 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12031 POSTS0 COMMENTS
Shaida Kate Naidoo
6951 POSTS0 COMMENTS
Ted Musemwa
7202 POSTS0 COMMENTS
Thapelo Manthata
6898 POSTS0 COMMENTS
Umr Jansen
6882 POSTS0 COMMENTS