1Z0-829 Working with Arrays and Collections Practice Question
Which THREE of the following are valid ways to create a new ArrayList<Integer>? (Select three.)
⚠ Common exam trap
It's easy for candidates to confuse `Arrays.asList` with `ArrayList` and attempt to cast the returned list directly, not realizing it is a different class that cannot be cast to `ArrayList`.
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
✓
new ArrayList<>(Arrays.asList(1,2,3))
`Arrays.asList(1,2,3)` returns a fixed-size `List<Integer>`, and passing it to the `ArrayList` constructor creates a new, mutable `ArrayList<Integer>` containing the same elements. This is a standard way to initialize an `ArrayList` with known values.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
new ArrayList<>(Arrays.asList(1,2,3))
Why this is correct
Creates an ArrayList from the List returned by Arrays.asList.
- ✗
new ArrayList<>(10, 20, 30)
Why it's wrong here
No constructor takes varargs of elements; this is invalid syntax.
- ✓
new ArrayList<>(List.of(1,2,3))
Why this is correct
Creates an ArrayList with elements 1,2,3 from an immutable list.
- ✗
(ArrayList<Integer>) Arrays.asList(1,2,3)
Why it's wrong here
Casting to ArrayList fails at runtime because Arrays.asList returns a java.util.Arrays.ArrayList (a private inner class) not java.util.ArrayList.
- ✓
new ArrayList<Integer>() with initial capacity 10
Why this is correct
Creates an empty ArrayList with initial capacity 10.
Go deeper
Related to this question
About these practice questions
One of 513 original 1Z0-829 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
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.