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 2 students

Invalid 2D Array Index Type

Mark
< Prev
Next >

What is the cause of the compilation error in the provided code segment?

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

Incorrect use of the System.out.println method.

B

Improper dimensions used when declaring the 2D array.

C

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

D

The array ‘table’ is not properly declared.

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|