Question:medium

Which keyword is used to define a constant in Java?

Show Hint

The convention in Java for naming constants (variables declared as `public static final`) is to use all uppercase letters, with words separated by underscores, like `MAX_VALUE`.
Updated On: Jul 2, 2026
  • final
  • const
  • static
  • volatile
Show Solution

The Correct Option is A

Solution and Explanation

Step 1: Understand what being a constant really requires.
A constant is a value that, once given, must never change for the rest of the program's run, so the language needs a keyword that locks a variable in place right after its first assignment.
Step 2: See how Java enforces this lock.
Marking a variable with final tells the compiler to reject any later attempt to reassign it, so a line like final double PI = 3.14159 guarantees PI can never be changed anywhere afterward in the program.
Step 3: Rule out the lookalike keywords.
const is reserved in Java but never actually implemented, static only controls whether a member belongs to the class rather than to an instance, and volatile is about memory visibility across threads, none of which by themselves create an unchangeable value.
\[ \boxed{\text{final}} \]
Was this answer helpful?
0