1Z0-811 Primitives, Strings and Operators Practice Question
Which THREE of the following expressions compile without error? (Choose 3)
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
✓
byte b = 1 + 2;
Options A, C, D are correct. A: byte addition promoted to int, then assigned to byte requires explicit cast? Actually byte + byte = int, but assignment to byte will require explicit cast. Wait: byte b = 1+2? 1 and 2 are literals, compile-time constant, so assignment is allowed because constant expression. Actually 1 and 2 are int literals, but the result is compile-time constant 3, which fits in byte, so it's allowed. So A compiles. B: int + long = long, assigning to int requires explicit cast, so compile error. C: double d = 10; 10 is int, widening assignment to double is fine. D: boolean b = (false || true); boolean expression, fine. E: float f = 5.5; 5.5 is double by default, requires explicit cast or f suffix, so compile error. So correct: A, C, D.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
byte b = 1 + 2;
Why this is correct
Compile-time constant, fits byte.
- ✗
int i = 5L + 10;
Why it's wrong here
Long + int = long, cannot assign to int without cast.
- ✓
double d = 10;
Why this is correct
Widening from int to double.
- ✓
boolean b = (false || true);
Why this is correct
Boolean expression.
- ✗
float f = 5.5;
Why it's wrong here
5.5 is double, needs f suffix or cast.
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.