1Z0-811 Primitives, Strings and Operators Practice Question
Exhibit
Refer to the exhibit.
javac Test.java
Test.java:3: error: incompatible types: possible lossy conversion from int to byte
byte b = 200;
^
1 errorWhat is the cause of the compilation error?
⚠ Common exam trap
A common mix-up: candidates confuse the range of byte with that of short or int, or mistakenly think the error is due to the literal being a long, when in fact Java treats all unsuffixed integer literals as int.
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
✓
The value 200 exceeds the range of byte (-128 to 127)
The code attempts to assign the integer literal 200 to a variable of type byte. In Java, the byte data type has a range from -128 to 127. Since 200 exceeds this range, the compiler detects a possible loss of precision and raises a compilation error. Java does not automatically narrow a larger integer literal to fit into a byte without an explicit cast.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
The value 200 exceeds the range of byte (-128 to 127)
Why this is correct
Correct: 200 > 127, so cannot be assigned to byte without cast.
- ✗
The literal 200 is a long
Why it's wrong here
Incorrect: 200 is an int literal by default.
- ✗
The assignment operator is invalid
Why it's wrong here
Incorrect: = is a valid assignment operator.
- ✗
The variable b is not declared
Why it's wrong here
Incorrect: 'byte b' declares the variable.
Go deeper
Related to this question
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 →
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.