LawMint Sign in

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
  1. final
    (correct answer)
  2. static
  3. constant
  4. 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