1Z0-811 Arrays and Methods Practice Question
An application requires storing a fixed set of 12 monthly temperatures. Which initialization is most appropriate?
⚠ Common exam trap
Oracle often tests the distinction between array declaration with an initializer list versus just allocating an array with default values, and the trap here is that candidates may choose Option B because it specifies the correct size, but overlook that it does not actually store the required temperature data.
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
✓
double[] temps = {15.5, 16.2, 18.0, 20.1, 23.4, 27.8, 30.0, 29.5, 26.2, 22.0, 18.5, 16.0};
It initializes a fixed-size array of 12 doubles with the actual monthly temperature values in a single statement, which is the most appropriate for storing a fixed set of 12 values. The array size is implicitly determined by the number of elements in the initializer list, and the syntax is concise and readable for this use case.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
ArrayList<Double> temps = new ArrayList<>();
Why it's wrong here
Not an array, and not fixed-size.
- ✗
double[] temps = new double[12];
Why it's wrong here
Creates array but elements default to 0.0, not the actual temperatures.
- ✓
double[] temps = {15.5, 16.2, 18.0, 20.1, 23.4, 27.8, 30.0, 29.5, 26.2, 22.0, 18.5, 16.0};
Why this is correct
Directly initializes with the needed values.
- ✗
double temps[] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
Why it's wrong here
All zeros, not real values.
Go deeper
Related to this question
About these practice questions
One of 481 original 1Z0-811 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-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.