1Z0-811 Arrays and Methods Practice Question
Which TWO statements are correct about array declaration and initialization in Java?
⚠ Common exam trap
Oracle often tests the distinction between C-style array syntax and Java's strict rules, specifically that you cannot combine a size specifier with an initializer list, and that size is never placed in the declaration brackets in Java.
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[] a = new int[5];
`int[] a = new int[5];` declares an array of integers with a size of 5 and initializes all elements to their default value (0 for int). This is the standard syntax for array declaration and initialization in Java, where the size is specified after `new`.
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[] a = new int[5];
Why this is correct
Valid declaration and allocation.
- ✗
int a[5];
Why it's wrong here
Cannot specify size in declaration.
- ✓
int[] a = {1, 2, 3};
Why this is correct
Valid array initialization with values.
- ✗
int a[5] = new int[5];
Why it's wrong here
Invalid; size cannot appear in left side.
- ✗
int[] a = new int[5] {1,2,3,4,5};
Why it's wrong here
Cannot combine size and initializer; must omit size.
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.