Question 98 of 481
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
Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →
Last reviewed: Jun 25, 2026
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.
Question Discussion
Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.
Sign in to join the discussion.