Courseiva
Primitives, Strings and OperatorseasyMultiple ChoiceObjective-mapped

1Z0-811 Type casting Practice Question

Given the code snippet: double d = 10.5; int i = (int) d; System.out.println(i); What is the output?

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

10

Casting a double to int truncates the fractional part, so 10.5 becomes 10. Option A (10.0) is incorrect because the result is an int without decimals; Option B is the original value; Option D is incorrect because the code compiles and runs.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • 10.0

    Why it's wrong here

    This option states '10', but it is marked as incorrect because the question contains a duplicate of the correct answer; the intended correct choice is C.

  • 10.5

    Why it's wrong here

    This is the original double value, but casting to int removes the fractional part, so the output is an integer.

  • 10

    Why this is correct

    Correct: Casting a double to int truncates the fractional part, so 10.5 becomes 10.

  • Compilation error

    Why it's wrong here

    Compilation error occurs only if there is a syntax error or incompatible types, but this cast is valid.

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 →

How Courseiva writes practice questions · Editorial policy

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.