Home » Java Programming » Declarations and Access Control

Which three form part of correct array declarations? public int a [ ] static int [ ] a public [ ] int a private int a [3] private int [3] a [ ] public final int [ ] a

Correct Answer: 1, 2, 6

Explanation:

(1), (2) and (6) are valid array declarations.


Option (3) is not a correct array declaration. The compiler complains with: illegal start of type. The brackets are in the wrong place. The following would work: public int[ ] a


Option (4) is not a correct array declaration. The compiler complains with: ']' expected. A closing bracket is expected in place of the 3. The following works: private int a []


Option (5) is not a correct array declaration. The compiler complains with 2 errors:


']' expected. A closing bracket is expected in place of the 3 and


<identifier> expected A variable name is expected after a[ ] .


← Previous Question Next Question→

More Questions from Declarations and Access Control

Discussion & Comments

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