Question 27 of 513
1Z0-829 Working with Arrays and Collections Practice Question
Given ArrayList<Integer> numbers = new ArrayList<>(List.of(1,2,3,4)); Which statement will insert element 10 at index 2?
⚠ Common exam trap
Many exam-takers confuse the `add(index, element)` method with `set(index, element)`, mistakenly thinking both insert, or they reverse the argument order, expecting `add(element, index)` as in some other languages.
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
✓
numbers.add(2,10);
The `ArrayList.add(int index, E element)` method inserts the specified element at the given index, shifting existing elements to the right. Here, `numbers.add(2,10)` inserts 10 at index 2, resulting in the list [1,2,10,3,4].
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
numbers.add(10,2);
Why it's wrong here
The add method expects index first, then element; this would attempt to add at index 10, causing IndexOutOfBoundsException.
- ✓
numbers.add(2,10);
Why this is correct
Inserts 10 at index 2, shifting subsequent elements to the right.
- ✗
numbers.set(2,10);
Why it's wrong here
set replaces the element at index 2, not insert.
- ✗
numbers.insert(2,10);
Why it's wrong here
No insert method exists in List or ArrayList.
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 25, 2026
This 1Z0-829 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-829 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.