Bird
0
0

Which of the following is the correct syntax to declare a constant in Java?

easy📝 Syntax Q3 of 15
Java - Custom Exceptions
Which of the following is the correct syntax to declare a constant in Java?
Aconst int MAX_VALUE = 100;
Bint MAX_VALUE = constant 100;
Cstatic int MAX_VALUE = 100;
Dfinal int MAX_VALUE = 100;
Step-by-Step Solution
Solution:
  1. Step 1: Recall Java constant declaration syntax

    Java uses 'final' keyword to declare constants.
  2. Step 2: Check each option

    final int MAX_VALUE = 100; uses 'final' correctly. 'const' is not a Java keyword. 'constant' keyword does not exist. 'static' alone doesn't make constant.
  3. Final Answer:

    final int MAX_VALUE = 100; -> Option D
  4. Quick Check:

    Constant declaration = final keyword [OK]
Quick Trick: Use 'final' keyword to declare constants [OK]
Common Mistakes:
  • Using 'const' keyword in Java
  • Forgetting 'final' keyword
  • Using 'static' alone for constants

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Java Quizzes