1Z0-811 Primitives, Strings and Operators Practice Question
A developer wants to assign the largest possible long value to a variable. Which is correct?
⚠ Common exam trap
Candidates may be tempted to use a numeric literal with L suffix, but the best practice is to use the Long.MAX_VALUE constant to avoid typos and improve readability.
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
✓
long x = Long.MAX_VALUE;
The correct answer is E. Long.MAX_VALUE is the standard and readable way to obtain the maximum long value. While option D (9223372036854775807L) is syntactically valid, it is not recommended because it is error-prone and does not clearly convey intent. Options A and C are incorrect: A has an unnecessary cast, and C omits the L suffix, causing a compile error. Option B exceeds the long range.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
long x = (long) 9223372036854775807L;
Why it's wrong here
This line compiles and assigns the correct value, but the explicit cast is redundant. However, it is still a valid assignment, though not the most straightforward.
- ✗
long x = 9223372036854775808L;
Why it's wrong here
The value 9223372036854775808L exceeds Long.MAX_VALUE, causing a compilation error.
- ✗
long x = 9223372036854775807;
Why it's wrong here
Missing the 'L' suffix causes the literal to be treated as an int, resulting in overflow.
- ✗
long x = 9223372036854775807L;
Why it's wrong here
This line correctly assigns the maximum long value using the literal with the required 'L' suffix.
- ✓
long x = Long.MAX_VALUE;
Why this is correct
This line uses the well-defined constant Long.MAX_VALUE, which is clear and maintainable.
- ✗
long x = 9223372036854775807;
Why it's wrong here
Literal without L is int; overflow.
- ✗
long x = (long) 1e19;
Why it's wrong here
Floating-point literal can't be assigned directly; casting truncates but still not the maximum.
Go deeper
Related to this question
About these practice questions
Courseiva writes every 1Z0-811 question from scratch — 481 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
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.