
AL-Two-Dimensional Array

Quiz
•
Computers
•
9th - 12th Grade
•
Medium

Arasaka Teacher
Used 3+ times
FREE Resource
13 questions
Show all answers
1.
FILL IN THE BLANK QUESTION
3 mins • 1 pt
Modify the top-right element of a 2D array to 1:
public class TwoDArrayOperations {
public static int[][] changeTopRight(int[][] arr) {
// Modify the top - right element to 1
return arr;
}
2.
DRAG AND DROP QUESTION
1 min • 1 pt
Calculate the sum of all even numbers in a 2D array
public static int sumEvenNumbers(int[][] arr) {
int sum = 0;
(a) {
(b) {
// 填写代码...
(c) {
(d) ;
}
}
}
return sum;}
3.
FILL IN THE BLANK QUESTION
3 mins • 2 pts
Find the maximum value in a 2D array
// 3. Count the number of all odd numbers in a 2D array
public static int countOddNumbers(int[][] arr) {
int count = 0;
for (int i = 0; i < arr.length; i++) {
for (int j = 0; j < arr[i].length; j++) {
______
{
_____
}
}
}
return count;
}
Answer explanation
countOddNumbers: Iterates through each element of the 2D array and checks if it is odd. If it is, increments the count.
4.
FILL IN THE BLANK QUESTION
1 min • 2 pts
// 4. Calculate the sum of each row in a 2D array
public static int[] sumEachRow(int[][] arr) {
int[] rowSums = new int[arr.length];
for (int i = 0; i < arr.length; i++) {
for (int j = 0; j < arr[i].length; j++) {
————————
;
}
}
return rowSums;
}
5.
FILL IN THE BLANK QUESTION
3 mins • 2 pts
// 5. Calculate the sum of each column in a 2D array
public static int[] sumEachColumn(int[][] arr) {
int[] colSums = new int[————————];
for (int j = 0; j < arr[0].length; j++) {
for (int i = 0; i < arr.length; i++) {
——————————;
}
}
return colSums;
}
6.
FILL IN THE BLANK QUESTION
3 mins • 1 pt
// 6. Find the maximum value in a 2D array
public static int findMax(int[][] arr) {
int —————— = arr[0][0];
for (int i = 0; i < arr.length; i++) {
for (int j = 0; j < arr[i].length; j++) {
if (_______) {
max = arr[i][j];
}
}
}
return max;
}
7.
FILL IN THE BLANK QUESTION
2 mins • 3 pts
// 7. Find the minimum value in a 2D array
public static int findMin(int[][] arr) {
int min = arr[0][0];
for (int i = 0; i < arr.length; i++) {
for (int j = 0; j < arr[i].length; j++) {
_______ {
min = arr[i][j];
}
}
}
return min;
}
Create a free account and access millions of resources
Similar Resources on Wayground
10 questions
AP CS A Unit 6 Quiz PRACTICE

Quiz
•
9th - 12th Grade
18 questions
ICT01: Introduction to MATLAB basics

Quiz
•
11th - 12th Grade
16 questions
Python массив

Quiz
•
9th Grade
10 questions
Le basi C++

Quiz
•
11th Grade
10 questions
Chapter 05 Worksheet

Quiz
•
10th Grade
15 questions
AP Computer Science A Review 1

Quiz
•
10th - 12th Grade
10 questions
C#

Quiz
•
11th Grade
8 questions
CAI710: WQ1

Quiz
•
12th Grade
Popular Resources on Wayground
10 questions
Video Games

Quiz
•
6th - 12th Grade
20 questions
Brand Labels

Quiz
•
5th - 12th Grade
15 questions
Core 4 of Customer Service - Student Edition

Quiz
•
6th - 8th Grade
15 questions
What is Bullying?- Bullying Lesson Series 6-12

Lesson
•
11th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
22 questions
Adding Integers

Quiz
•
6th Grade
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade
Discover more resources for Computers
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade
10 questions
Proper Keyboarding Techniques

Interactive video
•
6th - 10th Grade
14 questions
Inputs and Outputs: Computer Science Intro

Lesson
•
5th - 9th Grade
10 questions
Understanding Computers: Hardware, Software, and Operating Systems

Interactive video
•
7th - 12th Grade
29 questions
AP CSP Unit 2 Review (Code.org)

Quiz
•
10th - 12th Grade