Courseiva
Arrays and MethodsmediumMultiple ChoiceObjective-mapped

1Z0-811 Arrays and Methods Practice Question

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

⚠ Common exam trap

Oracle often tests the misconception that Java will always widen an int to a double when both overloads exist, leading candidates to incorrectly choose the double parameter method.

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

The method with int parameter

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.

Answer analysis

Option-by-option breakdown

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

  • The method with double parameter

    Why it's wrong here

    Would require implicit widening conversion, but int version is more specific.

  • Compilation error: ambiguous call

    Why it's wrong here

    No ambiguity because int version is a perfect match.

  • The method with int parameter

    Why this is correct

    The int version is the best match for an int argument.

  • Runtime error: NoSuchMethod

    Why it's wrong here

    Method exists and is resolved at compile time.

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

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. 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)); } } ```

easy
  • A.15.0
  • B.5.0
  • C.10.0
  • D.Compilation error: ambiguous method call

Why A: 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.

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.