Two Dimensional Arrays
9. Length of a 2D Array
Answer:
int[][] uneven =
{ { 1, 9, 4 },
{ 0, 2},
{ 0, 1, 2, 3, 4 } };
Which of the following exist?
- uneven[ 0 ][ 2 ] OK
- uneven[ 1 ][ 1 ] OK
- uneven[ 2 ][ 5 ] WRONG
- uneven[ 3 ][ 0 ] WRONG
Length of a 2D Array
class UnevenExample2 { public static void main( String[] arg ) { // declare and construct a 2D array int[][] uneven = { { 1, 9, 4 }, { 0, 2}, { 0, 1, 2, 3, 4 } }; System.out.println("Length is: " + uneven.length ); } } |
Question 9: