1Z0-811 Primitives, Strings and Operators Practice Question
Given: int a = 9; int b = 2; double c = a / b; System.out.println(c); What is the output?
⚠ Common exam trap
Oracle often tests the distinction between integer and floating-point division, trapping candidates who assume that assigning the result to a `double` variable automatically performs floating-point division.
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
✓
4.0
The expression `a / b` performs integer division because both operands are `int`. The result of `9 / 2` is `4` (the fractional part is truncated). This integer result is then implicitly widened to `double` when assigned to `c`, producing `4.0`. Therefore, the output is `4.0`.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
4.5
Why it's wrong here
The division is integer division, so result is 4, not 4.5. Therefore, this option is incorrect.
- ✓
4.0
Why this is correct
In integer division, 9/2 = 4, and since c is double, it becomes 4.0. This is correct.
- ✗
0.0
Why it's wrong here
Though the value 4.0 is correct, this option is marked incorrect because it is a duplicate of option B, and only one answer can be correct.
- ✗
4
Why it's wrong here
The result is 4.0 because c is of type double, not 4. Therefore, this option is incorrect.
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.