Difficulty: Easy
Correct Answer: 1, 2, 4
Explanation:
Introduction / Context:
Java supports several syntactic styles for array declarations, including placing brackets after the type or after the variable name. Some C-like forms are illegal in Java.
Given Data / Assumptions:
Concept / Approach:
Legal forms: type[] var; or type var[];. Multi-dimensional (jagged) arrays can be declared like int[] a[];. Illegal forms include specifying the size in the declaration without an initializer on the left-hand side (C-style).
Step-by-Step Solution:
Verification / Alternative check:
Try compiling each; (3) and (5) fail with syntax errors.
Why Other Options Are Wrong:
Any set including (3) or (5) is invalid.
Common Pitfalls:
Transferring C/C++ array syntax to Java; mixing declaration and allocation incorrectly.
Final Answer:
1, 2, 4
Discussion & Comments