Java Foundations — Question 2
Which statement is valid?
Answer options
- A. int 2 totalScore = 0;
- B. int total–score = 0;
- C. int totalScore2 = 0;
- D. int total score = 0;
Correct answer: C
Explanation
Option C is correct because it follows the proper syntax for variable declaration in most programming languages, using a valid identifier. The other options are incorrect due to invalid characters or formats: Option A starts with a digit, Option B uses an invalid character (–), and Option D has a space in the variable name.