Courseiva
Arrays and MethodsmediumMultiple ChoiceObjective-mapped

1Z0-811 Arrays and Methods Practice Question

A developer writes a method that takes a variable number of integer arguments and returns the maximum. Which method signature is correct?

⚠ Common exam trap

Oracle often tests the distinction between varargs (`int...`) and array parameters (`int[]`), trapping candidates who think they are interchangeable without understanding that varargs allows passing individual values directly while an array parameter requires explicit array creation.

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

public int max(int... numbers)

The varargs syntax `int... numbers` allows a method to accept zero or more integer arguments, which are then treated as an array inside the method. This is the standard Java syntax for variable-length argument lists, enabling the developer to pass any number of `int` values and compute the maximum.

Answer analysis

Option-by-option breakdown

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

  • public int max(int[]... numbers)

    Why it's wrong here

    This is a varargs of int arrays, which would accept multiple arrays, not individual integers.

  • public int max(int... numbers)

    Why this is correct

    Varargs allows zero or more arguments, and inside the method it is treated as an array of int.

  • public int max(int numbers)

    Why it's wrong here

    This accepts only a single int, not a variable number.

  • public int max(int[] numbers)

    Why it's wrong here

    This signature accepts an array, but not variable arguments directly; calling max(1,2,3) without an array literal is not allowed.

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

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.