Difficulty: Easy
Correct Answer: int [] a = {23, 22, 21, 20, 19};
Explanation:
Introduction / Context:
Arrays in Java are objects with fixed length. You can declare and initialize them in one statement using an initializer list, which is common for known small datasets.
Given Data / Assumptions:
Concept / Approach:
Use the brace form: type[] name = {v1, v2, ...}. This creates the array object and fills it with the specified values. The length is inferred from the list.
Step-by-Step Solution:
Verification / Alternative check:
Print a[0..4] after option B; it shows the listed values, not zeros.
Why Other Options Are Wrong:
They either lack initialization values or use invalid types/syntax.
Common Pitfalls:
Confusing Java with C-style declarations or assuming Array is a built-in type to construct directly.
Final Answer:
int [] a = {23, 22, 21, 20, 19};
Discussion & Comments