3 Multidimensional Arrays Flashcards

1
Q

What is the syntax to create a multidimensional array? List 4 ways

A

int[][] vars1; // 2D array
int vars2 [][]; // 2D array
int[] vars3[]; // 2D array
String [][] rectangle = new String[3][2];

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does this make? int[] vars4 [], space [][];

A

int[] vars4 [], space [][]; // a 2D AND a 3D array

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Write a loop that initializes a two D array.

A

x

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Do the elements on next levels of a multidimensional array have to be the same size? Give an example.

A

No. They can be different sizes.

int[][] differentSize = {{1, 4}, {3}, {9,8,7}};

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

T or F, only the size of the first level of a multidimensional array has to be declared.

A

True. int [][] args = new int[4][]; is fine.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Write a loop to initialize every element of a twoD array and then for a 3D array.
Write them with a for loop and with an enhanced for loop.

A

x

How well did you know this?
1
Not at all
2
3
4
5
Perfectly