| 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 2 students
Invalid 2D Array Index Type
< Prev
Next >

Identify the error that causes the code above to fail compilation.

public class IndexError {
    public static void main(String[] args) {
        int[][] table = { {1, 2, 3}, {4, 5, 6} };
        int element = table['0'][1];
        System.out.println(element);
    }
}
A

Using a character literal ‘0’ as an array index instead of an integer.

B

The array ‘table’ is not properly declared.

C

Incorrect use of the System.out.println method.

D

Improper dimensions used when declaring the 2D array.

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.

No comments yet. Be the first to comment!

AI Tutor

How can I help?

APFIVE © 2020.
Email: [email protected]|Privacy Policy