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-taxiA Java variable name can contain letters, digits, underscores, and dollar signs, but it cannot contain a hyphen. Therefore rate-of-taxi is invalid.

  1. A.

    x15

  2. B.

    rate

  3. C.

    rate_of_taxi

  4. D.

    rate-of-taxi

  5. 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.

Explore the full course: Rssb Basic Computer Instructor

Loading lesson…