
AP Computer Science - 2 D Arrays

Quiz
•
Computers
•
9th - 12th Grade
•
Hard
John Miller
Used 121+ times
FREE Resource
6 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
//Precondition: mat is initialized
public static void matStuff(int[][] mat, int row)
{
int numCols = mat[0].length;
for (int col = 0; col < numCols; col++)
mat[row][col] = row;
}
Suppose mat is originally
1 4 9 0
2 7 8 6
5 1 4 3
After the method call matStuff(mat, 1), matrix mat will be
1 1 1 1
2 7 8 6
5 1 4 3
1 4 9 0
1 7 8 6
1 1 4 3
1 1 9 0
2 1 8 6
5 1 4 3
1 4 9 0
1 1 1 1
5 1 4 3
1 1 1 1
1 1 1 1
1 1 1 1
2.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Which of the following initializes an 8 X 10 matrix with integer values that are prefect squares (0 is a perfect square)?
I int[][] mat = new int[8][10];
II int[][] mat = new int[8][10];
for(int r = 0; r < mat.length; r++)
for(int c = 0; c < mat[r].length; c++)
mat[r][c] = r - r;
III int[][] mat = new int[8][10];
for(int c = 0; c < mat[0].length; c++)
for(int r = 0; r < mat.length; r++)
mat[r][c] = c * c;
I only
II only
III only
I and II only
I and III only
3.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Given the following matrix definition:
double [][] a = new double[5][8];
This array will hold the following values after it is instantiated:
Zeros
False
No values, each element will be empty
Random Numbers
Null
4.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Given the following matrix definition:
boolean[][] a = new boolean[5][8];
This array will hold the following values after it is instantiated:
Zeros
False
No values, each element will be empty
Random Numbers
Null
5.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Consider a class that has this private instance variable:
private int[][] mat;
The class has the following method, alter.
public void alter (int c)
{
for (int i = 0; i < mat.length; i++)
for (int j = c + 1; j < mat[0].length; j++)
mat[i][j – 1] = mat [i][j];
}
If a 3 x 4 matrix mat is
1 3 5 7
2 4 6 8
3 5 7 9
then alter(1) will change mat to
1 5 7 7
2 6 8 8
3 7 9 9
1 5 7
2 6 8
3 7 9
1 3 5 7
3 5 7 9
1 3 5 7
3 5 7 9
3 5 7 9
1 7 7 7
2 8 8 8
3 9 9 9
6.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
I only
II only
III only
I and II only
I, II, and III
Similar Resources on Wayground
10 questions
Variabel dan Tipe Data

Quiz
•
10th Grade
10 questions
C# lesson10

Quiz
•
1st - 10th Grade
10 questions
THỰC HÀNH SỐ 1

Quiz
•
12th Grade
10 questions
Pop Quiz

Quiz
•
11th Grade
10 questions
Programski jezik C (do 2.5.2)

Quiz
•
9th Grade
10 questions
AP CSA Unit 1 & 2 Review

Quiz
•
9th - 12th Grade
9 questions
C sharp

Quiz
•
11th Grade
10 questions
Kuis Percabangan dan Perulangan

Quiz
•
10th Grade
Popular Resources on Wayground
50 questions
Trivia 7/25

Quiz
•
12th Grade
11 questions
Standard Response Protocol

Quiz
•
6th - 8th Grade
11 questions
Negative Exponents

Quiz
•
7th - 8th Grade
12 questions
Exponent Expressions

Quiz
•
6th Grade
4 questions
Exit Ticket 7/29

Quiz
•
8th Grade
20 questions
Subject-Verb Agreement

Quiz
•
9th Grade
20 questions
One Step Equations All Operations

Quiz
•
6th - 7th Grade
18 questions
"A Quilt of a Country"

Quiz
•
9th Grade
Discover more resources for Computers
50 questions
Trivia 7/25

Quiz
•
12th Grade
20 questions
Subject-Verb Agreement

Quiz
•
9th Grade
18 questions
"A Quilt of a Country"

Quiz
•
9th Grade
6 questions
RL.10.1 Cite Evidence

Quiz
•
10th Grade
10 questions
Characteristics of Life

Quiz
•
9th - 10th Grade
14 questions
Algebra 1 SOL Review #1

Quiz
•
9th Grade