Courseiva
Arrays and MethodseasyMultiple ChoiceObjective-mapped

1Z0-811 Implicit Widening Conversion Practice Question

Exhibit

Refer to the exhibit.
public class Calculator {
    public static int add(int a, int b) {
        return a + b;
    }
    public static double add(double a, double b) {
        return a + b;
    }
    public static void main(String[] args) {
        double result = add(5, 10);
        System.out.println(result);
    }
}

What is the output when the main method is executed?

```java

public class Test {
    public static double add(double a, double b) {
        return a + b;
    }
    public static void main(String[] args) {

System.out.println(add(5, 10));

}
}

```

⚠ Common exam trap

Candidates may mistakenly believe that integer arguments cannot be passed to a double parameter without explicit casting, or that the compiler would report an ambiguous method call. In this case, only one method exists and widening is automatic.

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

15.0

The code defines a single method `public static double add(double a, double b) { return a + b; }`. The main method calls `System.out.println(add(5,10));`. Java performs implicit widening conversion of the integer literals 5 and 10 to double, resulting in 15.0. Options 5.0 and 10.0 would be incorrect because the method adds the arguments. Option D is incorrect because there is no ambiguity — only one method matches after widening.

Answer analysis

Option-by-option breakdown

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

  • 15.0

    Why this is correct

    Correct. The integers are widened to double and summed as 5.0 + 10.0 = 15.0.

  • 5.0

    Why it's wrong here

    Incorrect. 5.0 would be the result if only one argument was doubled, but the sum of both is 15.0.

  • 10.0

    Why it's wrong here

    Incorrect. 10.0 would be the result if only one argument was processed, not both.

  • Compilation error: ambiguous method call

    Why it's wrong here

    Incorrect. No ambiguity: only one overload is applicable after widening, so compilation succeeds.

About these practice questions

Courseiva writes every 1Z0-811 question from scratch — 481 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

Same concept, more angles

1 more way this is tested on 1Z0-811

These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.

Variation 1. A developer writes two methods: public void process(int a) { ... } and public void process(double a) { ... }. Which method is called by process(10)?

medium
  • A.The method with double parameter
  • B.Compilation error: ambiguous call
  • C.The method with int parameter
  • D.Runtime error: NoSuchMethod

Why C: Java selects the most specific overloaded method at compile time. When calling process(10), the integer literal 10 is an int, so the compiler prefers the method with the int parameter over the double parameter, as no implicit widening conversion is required.

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.