Question 374 of 481
1Z0-811 Arrays and Methods Practice Question
A developer writes a method that takes an int array and returns the sum of its elements. The method signature is: 'public static int sumArray(int[] arr)'. Which statement correctly calls this method?
⚠ Common exam trap
Oracle often tests the distinction between array initializer syntax (valid only in declarations) and anonymous array syntax (required when passing an array directly to a method), causing candidates to mistakenly use `[1,2,3]` or a single value instead of the proper `new int[]{...}` form.
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 result = sumArray(new int[]{1,2,3});
It uses the correct syntax for creating and passing an anonymous int array to the sumArray method. The expression `new int[]{1,2,3}` creates an int array object with the specified elements, which matches the method's parameter type `int[]`. The method then returns the sum, which is assigned to the int variable `result`.
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 result = sumArray(new int[]{1,2,3});
Why this is correct
This statement correctly invokes the `sumArray` method by providing an `int` array argument, precisely matching the `int[] arr` parameter defined in the method signature. The `new int[]{1,2,3}` syntax creates an anonymous integer array literal, which is then correctly passed to the static method. The method's `int` return value is subsequently assigned to the `int result` variable, ensuring type compatibility. This demonstrates the correct mechanism for passing an array argument to a static method.
- ✗
int result = sumArray(true);
Why it's wrong here
Passes a boolean, not an array.
- ✗
int result = sumArray([1,2,3]);
Why it's wrong here
Invalid syntax; use new int[]{...}.
- ✗
int result = sumArray(5);
Why it's wrong here
Passes an int, not an array.
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 →
Last reviewed: Jun 30, 2026
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.