The answer is 15.0. This is correct because when the main method calls `sum(5, 10)`, Java’s overloaded method selection applies a widening conversion: the two integer literals are implicitly widened to `double` to match the `sum(double a, double b)` method, since no exact `int` parameter match exists. The method then returns `5.0 + 10.0`, producing `15.0`. On the Oracle Java Foundations 1Z0-811 exam, this tests your understanding of how the compiler resolves overloaded methods when no exact signature is found—widening is preferred over boxing or varargs. A common trap is assuming the integers stay as `int` and cause a compilation error, but Java automatically promotes smaller types to larger ones in method calls. Remember the mnemonic: “Widen before you box”—Java always tries the least invasive conversion first, and widening an `int` to a `double` is seamless.
1Z0-811 Arrays and Methods Practice Question
This 1Z0-811 practice question tests your understanding of arrays and methods. Read the scenario carefully and evaluate each option against the stated constraints before committing to an answer. After answering, compare your reasoning against the explanation and wrong-answer breakdown below. Once you have made your selection, read the full explanation to reinforce the concept and understand why each distractor is designed to mislead on exam day.
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?
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);
}
}
A
15.0
The int addition yields 15, promoted to double.
B
5.0
Why wrong: Not the result of addition.
C
10.0
Why wrong: Not the result.
D
Compilation error: ambiguous method call
Why wrong: No ambiguity; int version is best match.
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 correct answer is A (15.0) because the method call `sum(5, 10)` matches the overloaded method `sum(double a, double b)` after the integer literals are implicitly widened to `double`. The method returns `a + b`, which is `5.0 + 10.0 = 15.0`, and since the return type is `double`, the output is `15.0`.
Key principle: Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.
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
The int addition yields 15, promoted to double.
Related concept
Read the scenario before looking for a memorised answer.
✗
5.0
Why it's wrong here
Not the result of addition.
✗
10.0
Why it's wrong here
Not the result.
✗
Compilation error: ambiguous method call
Why it's wrong here
No ambiguity; int version is best match.
Common exam traps
Common exam trap: answer the scenario, not the keyword
Oracle often tests the concept of implicit widening conversion in method overloading, where candidates mistakenly think integer arguments must match an `int` parameter exactly or that the call would be ambiguous, when in fact the compiler silently widens to the only compatible `double` overload.
Detailed technical explanation
How to think about this question
In Java, when an overloaded method is called with arguments that do not exactly match any parameter list, the compiler applies widening primitive conversion (e.g., `int` to `double`) before reporting an error. This is defined in JLS §5.1.2. In real-world scenarios, such implicit widening can lead to unexpected precision loss or method selection if multiple overloads accept different numeric types, so developers should be explicit about types when precision matters.
KKey Concepts to Remember
Read the scenario before looking for a memorised answer.
Find the constraint that changes the correct option.
Eliminate answers that are true in general but not in this case.
TExam Day Tips
→Watch for words such as best, first, most likely and least administrative effort.
→Review why wrong options are wrong, not only why the correct option is correct.
Key takeaway
Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.
Real-world example
How this comes up in practice
A practitioner preparing for the 1Z0-811 exam encounters this exact type of scenario on the job. The correct answer here is not the most general option — it is the best answer for the specific constraint described. Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option. Real exam questions reward reading the full scenario before eliminating options, because the constraint defines which answer fits.
What to study next
Got this wrong? Here's your next step.
Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.
Arrays and Methods — This question tests Arrays and Methods — Read the scenario before looking for a memorised answer..
What is the correct answer to this question?
The correct answer is: 15.0 — The correct answer is A (15.0) because the method call `sum(5, 10)` matches the overloaded method `sum(double a, double b)` after the integer literals are implicitly widened to `double`. The method returns `a + b`, which is `5.0 + 10.0 = 15.0`, and since the return type is `double`, the output is `15.0`.
What should I do if I get this 1Z0-811 question wrong?
Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.
What is the key concept behind this question?
Read the scenario before looking for a memorised answer.
About these practice questions
Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →
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: Option C is correct because 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.
Last reviewed: Jun 30, 2026
Question Discussion
Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.
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.
Question Discussion
Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.
Sign in to join the discussion.