The keyword used to prevent a variable from being modified in Java is
The keyword used to prevent a variable from being modified in Java is
- final(correct answer)
- static
- constant
- readonly
Answer and explanation
Correct answer: A - final
Declaring a variable final in Java makes it a constant once assigned. 'const' is reserved but unused, and constant/readonly are not Java keywords.
Practice for these exams
-
CUSAT CAT M.Sc. Forensic Science
-
Uttarakhand Judicial Services