Courseiva
Java Basics and SyntaxeasyMultiple SelectObjective-mapped

1Z0-811 Java Basics and Syntax Practice Question

Which TWO are valid Java identifiers? (Choose two.)

⚠ Common exam trap

Watch out — candidates often think the dollar sign ($) is invalid because it is not a letter, or that the underscore (_) is only allowed in the middle of an identifier, but both are explicitly permitted as starting characters by the JLS.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

$test

($test) is a valid Java identifier because identifiers can begin with a dollar sign ($) or an underscore (_), followed by any combination of letters, digits, dollar signs, or underscores. The Java Language Specification (JLS §3.8) explicitly allows the dollar sign as a starting character, though it is conventionally reserved for mechanically generated names.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • $test

    Why this is correct

    Dollar sign is allowed as first character.

  • class

    Why it's wrong here

    'class' is a reserved keyword.

  • my-var

    Why it's wrong here

    Hyphen is not allowed in identifiers.

  • _myVar

    Why this is correct

    Underscore is allowed as first character.

  • 2ndVar

    Why it's wrong here

    Cannot start with a digit.

About these practice questions

This 1Z0-811 question is part of Courseiva's 481-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This 1Z0-811 practice question is part of Courseiva's free Oracle certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the 1Z0-811 exam.