Moderate

Which of the following statements about arrays is syntactically wrong ?

Correct answer: D. arrayName p[5];

  • A. arrayName[] p = new arrayName[5];
  • B. arrayName p[][] = new arrayName[2][];
  • C. arrayName[] p [];
  • D. arrayName p[5];

Explanation

Java allows the brackets to appear after the type or variable, and an incomplete second dimension is valid in a declaration. `arrayName p[5]` is invalid because Java array sizes belong in the `new` expression, not in the variable declaration.

Last updated

Practise Software Design and Architecture

493 free Software Design and Architecture MCQs from Software Engineering, each with the correct answer and an explanation. Unlimited attempts, no account needed.

Exams that ask Software Engineering questions like this

Software Engineering is on this paper prepared for on TestUstad, and all of them draw the same bank, so this question is worth knowing for it.

Related questions