Are you taking CLEP classes? Try clep.ai
| preferred AP College board partner for AP classes
AP Computer Science A/Unit 8: 2D Array
Start Practice TestPractice Test
About Exam
easy Solved by 1 students

Java 2D Array Initialization Syntax

Mark
< Prev
Next >

What is the reason the following code fails to compile?

public class ArrayError {
    public static void main(String[] args) {
        int[][] numbers = new int[2,3];
        System.out.println(numbers[0][0]);
    }
}
A

The print statement is missing a semicolon at the end.

B

The array is declared with incorrect syntax using a comma instead of separate square brackets for each dimension.

C

The main method is not defined as static.

D

The variable ‘numbers’ is not properly initialized.

Hint
Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer
Report Question

Question Leaderboard

Not enough data yet to show leaderboard.

AI Tutor

How can I help?

APFIVE © 2020.
Email: apfive@apfive.org|Privacy Policy|