Courseiva
Java Basics and SyntaxeasyMultiple ChoiceObjective-mapped

1Z0-811 Binary Numeric Promotion Practice Question

Exhibit

public class Test {
    public void print(int i) { System.out.println("int"); }
    public void print(double d) { System.out.println("double"); }
    public static void main(String[] args) {
        Test t = new Test();
        t.print(10);
    }
}

Refer to the exhibit. What is the output?

⚠ Common exam trap

Candidates often overlook the explicit cast and think the division is between int and double, leading to a double result. However, with the cast, the division is integer, and the method overload resolution selects the int version.

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

int

The code performs an integer division because the double y is cast to int, making both operands int. The result is an int value of 2. The method typeOf(int) is called, which prints the string 'int'.

Answer analysis

Option-by-option breakdown

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

  • int

    Why this is correct

    Correct. The argument is an int due to the cast, so the int version is called, printing 'int'.

  • double

    Why it's wrong here

    Incorrect. The argument is not a double because the cast makes it an int.

  • Runtime error

    Why it's wrong here

    A runtime error would occur only if the code attempted an illegal operation, such as accessing an invalid index or dividing by zero, but the exhibit shows no such operation; the loop iterates within array bounds and performs only integer arithmetic. This option is tempting because runtime errors are common when a program tries to use an uninitialised variable or exceed array length, and in a scenario where the loop condition mistakenly allowed an out-of-bounds access, a runtime exception would indeed be the correct answer.

  • Compilation error

    Why it's wrong here

    Incorrect. The code compiles successfully.

About these practice questions

One of 481 original 1Z0-811 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. 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.