
Slides8.1_2DArrays
Presentation
•
Computers
•
11th Grade
•
Practice Problem
•
Medium
Lauren Wheelwright
Used 1+ times
FREE Resource
23 Slides • 5 Questions
1
2
1D Arrays - Review
String[] arr1 = new String[6];
0 | 1 | 2 | 3 | 4 | 5 |
|---|---|---|---|---|---|
null | null | null | null | null | null |
boolean[] arr2 = new boolean[2];
i=0 | i=1 |
|---|---|
false | false |
3
1D Arrays - Review
String[] arr1 = new String[6];
arr1[2] = "yay!";
0 | 1 | 2 | 3 | 4 | 5 |
|---|---|---|---|---|---|
null | null | "yay!" | null | null | null |
boolean[] arr2 = new boolean[2];
arr2[arr2.length - 1] = true;
i=0 | i=1 |
|---|---|
false | true |
4
2D Arrays
String[][] arr1 = new String[3][5];
null | null | null | null | null |
|---|---|---|---|---|
null | null | null | null | null |
null | null | null | null | null |
5
2D Arrays
String[][] arr1 = new String[3][5];
null | null | null | null | null |
|---|---|---|---|---|
null | null | null | null | null |
null | null | null | null | null |
# Rows
{
6
2D Arrays
String[][] arr1 = new String[3][5];
null | null | null | null | null |
|---|---|---|---|---|
null | null | null | null | null |
null | null | null | null | null |
# Rows
{
# Columns
7
2D Arrays
String[][] arr1 = new String[3][5];
null | null | null | null | null |
|---|---|---|---|---|
null | null | null | null | null |
null | null | null | null | null |
# Rows
{
# Columns
Type stored
8
Multiple Choice
What is the proper syntax to initialize a 6x6 2D String array?
String[] array = new String[6][6];
int[][] array = new int[6][6];
String[][] array = new String[6];
String[][] array = new String[6][6];
9
int[] arr = {5,8,9,4};
i=0 | i=1 | i=2 | i=3 |
|---|---|---|---|
5 | 8 | 9 | 4 |
10
int[][] arr = {
{3,4,5},
{6,7,8},
{9,0,1}
};
int[] arr = {5,8,9,4};
i=0 | i=1 | i=2 | i=3 |
|---|---|---|---|
5 | 8 | 9 | 4 |
3 | 4 | 5 |
|---|---|---|
6 | 7 | 8 |
9 | 0 | 1 |
11
int[][] arr = {
{3,4,5},
{6,7,8},
{9,0,1}
};
int[] arr = {5,8,9,4};
i=0 | i=1 | i=2 | i=3 |
|---|---|---|---|
5 | 8 | 9 | 4 |
3 | 4 | 5 |
|---|---|---|
6 | 7 | 8 |
9 | 0 | 1 |
int arr[][] = {
{4,3},
{1,8},
{7,9}
};
4 | 3 |
|---|---|
1 | 8 |
7 | 9 |
I know this looks made up, but it's legit!
12
Multiple Choice
Which of these would cause a compilation error?
String[][] w = new int[4][3];
boolean[][] y = {{true,false}, {false, true}};
int z[][] = {{3,4}, {5,6}, {7,8}};
int[][] x = new int[0][0];
13
int[][] x = new int[4][3];
// Print # rows
System.out.println(_________);
// Print # columns
System.out.println(_________);
type[][] name = new type[rows][cols];
0 | 0 | 0 |
|---|---|---|
0 | 0 | 0 |
0 | 0 | 0 |
0 | 0 | 0 |
14
int[][] x = new int[4][3];
// Print # rows
System.out.println(x.length);
// Print # columns
System.out.println(_________);
type[][] name = new type[rows][cols];
0 | 0 | 0 |
|---|---|---|
0 | 0 | 0 |
0 | 0 | 0 |
0 | 0 | 0 |
15
int[][] x = new int[4][3];
// Print # rows
System.out.println(x.length);
// Print # columns
System.out.println(x[0].length);
type[][] name = new type[rows][cols];
0 | 0 | 0 |
|---|---|---|
0 | 0 | 0 |
0 | 0 | 0 |
0 | 0 | 0 |
16
Multiple Choice
int[][] grid = new int[5][3]
What is the value of grid.length?
0
5
3
15
17
Multiple Choice
int[][] grid = new int[5][3]
What is the value of grid[0].length?
0
5
3
15
18
int[][] x = {
{9,8,7},
{6,5,4},
{3,2,1},
{0, -1, -2}
};
System.out.println(x[2][1]);
9 | 8 | 7 |
|---|---|---|
6 | 5 | 4 |
3 | 2 | 1 |
0 | -1 | -2 |
19
int[][] x = {
{9,8,7},
{6,5,4},
{3,2,1},
{0, -1, -2}
};
System.out.println(x[2][1]);
9 | 8 | 7 |
|---|---|---|
6 | 5 | 4 |
3 | 2 | 1 |
0 | -1 | -2 |
20
int[][] x = {
{9,8,7},
{6,5,4},
{3,2,1},
{0, -1, -2}
};
System.out.println(x[2][1]);
// Prints 2
9 | 8 | 7 |
|---|---|---|
6 | 5 | 4 |
3 | 2 | 1 |
0 | -1 | -2 |
21
Multiple Choice
A 2D array is initialized:
int [][] array = {{1,2,3},{4,5,6},{7,8,9}};
What is the result of array[0][1] + array[2][0]?
10
15
9
5
22
The updateValue method changes the value in arr at [row][col] to value
Call updateValue 3 times
public static void updateValue(int[][] arr, int row, int col, int value)
Set last value of first array to the length of the entire 2D array.
Set last value of 2nd array to the total number of values in the entire 2D array.
Set last value of 3rd array to the sum of the 1st value in 2D array and last value in 2D array.
updateValue(myArray, 1, myArray[0].length-1, 12);
The line above sets the last value of the 2nd array to 12
23
TODO
Initialize an 8x8 2D String array
Add all chess pieces to the board!
chess[0][0] = "Rook"; // sets the top left square to "Rook"
24
25
26
27
28
Show answer
Auto Play
Slide 1 / 28
SLIDE
Similar Resources on Wayground
21 questions
6.3 Graphing Rational Functions
Presentation
•
10th - 12th Grade
21 questions
Algoritma
Presentation
•
10th Grade
22 questions
Limit Fungsi Aljabar
Presentation
•
11th Grade
20 questions
Wave Unit Review
Presentation
•
11th Grade
21 questions
Pengenalan Kode Program Python (Bag II)
Presentation
•
11th Grade
22 questions
Revision Session
Presentation
•
11th Grade
21 questions
Моделирование в биологии
Presentation
•
11th Grade
20 questions
Algebra 2 Review
Presentation
•
11th Grade
Popular Resources on Wayground
10 questions
Safety Day 2026 – Student Review
Quiz
•
9th Grade
21 questions
Continents and Oceans
Quiz
•
6th Grade
20 questions
Parts of Speech
Quiz
•
5th Grade
16 questions
Subject & Predicate
Quiz
•
5th Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
12 questions
Map Skills
Quiz
•
3rd Grade
22 questions
Continents and Oceans
Quiz
•
5th Grade
15 questions
Rounding Decimals
Quiz
•
5th Grade