Which keyword in Java is used to declare a constant?
Answer
final
Answer
final
Which keyword in Java is used to declare a constant? The answer is `final`. Applied to a variable, `final` prevents that variable from being assigned a new value after initialization.
Java does not have a standalone `const` keyword for declaring constants; `const` is reserved but unused. A class-level constant is conventionally declared with both `static` and `final`, such as `public static final int MAX_USERS = 100;`. `static` means the field belongs to the class rather than each object, while `final` prevents reassignment.
A common mix-up is treating every `final` variable as a compile-time constant. A `final` variable may receive its value at runtime, such as from a constructor or method call. Java’s stricter “constant variable” definition generally involves a `final` primitive or `String` initialized with a constant expression. The keyword also applies to methods, which cannot be overridden, and classes, which cannot be subclassed.
Source: Wikipedia · fact-checked Aug. 2026