Vidyalelo
Java Programming · Q18

Data Types and Variables

Programming · Java Programming · question 18

Q18

What is the keyword used to declare a constant value in Java?

A.
constant
B.
const
C.
final
Answer
D.
static

Answer: Option C

Solution

Answer: Option C
Solution:
The correct answer is Option C: final.

In Java, the keyword used to declare a constant value is final.

Here's the breakdown:

Option A: constant - There is no constant keyword for declaring constants in Java.

Option B: const - There is no const keyword for declaring constants in Java. The const keyword is not used for this purpose in Java.

Option C: final - This is the correct keyword for declaring a constant value in Java. When you declare a variable as final, it means its value cannot be changed after initialization, making it a constant.

Option D: static - The static keyword is used to declare static variables and methods but not specifically for declaring constants.

So, the keyword used to declare a constant value in Java is final.