Java — Which three form part of correct array declarations?

Difficulty: Easy

Correct Answer: public int a[], static int[] a, public final int[] a

Explanation:


Introduction / Context:
This question checks the syntax for correct array declarations in Java.



Concept / Approach:
In Java arrays:

  • The brackets [] must follow either the type or the variable, but not the access modifier directly.
  • Array size cannot be given at declaration (e.g., int a[3] is invalid in Java).


Step-by-Step:

Option A: Valid declaration.Option B: Valid declaration.Option C: Invalid syntax.Option D: Invalid (size not allowed in declaration).Option E: Invalid (size inside brackets not allowed in declaration).


Final Answer:
1, 2, and 6

More Questions from Declarations and Access Control

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion