Which of the following is not a valid variable name in Java language?
2024
Which of the following is not a valid variable name in Java language?
Answer: D. rate-of-taxi — A Java variable name can contain letters, digits, underscores, and dollar signs, but it cannot contain a hyphen. Therefore rate-of-taxi is invalid.
- A.
x15
- B.
rate
- C.
rate_of_taxi
- D.
rate-of-taxi
- E.
Question not attempted
Attempted by 403 students.
Show answer & explanation
Correct answer: D
A Java variable name can contain letters, digits, underscores, and dollar signs, but it cannot contain a hyphen. Therefore rate-of-taxi is invalid.
Loading lesson…