AP CSA 2D arrays key terms
Key terms and concepts related to 2D arrays in AP Computer Science A.
Quiz(18 pytania)
1. What does `array.length` return for a 2D array?
Pojęcia w tym zestawie(19)
What is a 2D array?
An array of arrays, like a matrix, where each element is accessed by two indices.
Accessing an element
To access an element in a 2D array, use syntax: `array[row][column]`.
True or false: A 2D array can have different row sizes.
False, because all rows in a 2D array must have the same length.
Difference between row-major and column-major order.
Row-major stores rows in contiguous memory, while column-major stores columns.
How to initialize a 2D array?
Use `int[][] array = new int[rows][columns];` to create it.
What is the length of a 2D array?
Use `array.length` for rows and `array[0].length` for columns.
Fill in the blank: The first index in a 2D array represents the ___ .
row number.
What is a common use of 2D arrays?
Storing data in grid-like structures, such as game boards or matrices.
True or false: You can change the size of a 2D array after creation.
False, because arrays have fixed sizes in Java.
How do you iterate through a 2D array?
Use nested loops: `for(int i = 0; i < rows; i++) { for(int j = 0; j < cols; j++) { ... }}`.
What is the maximum index for a 2D array with 3 rows and 4 columns?
Row index: 2, Column index: 3, since indexing starts at 0.
Define a jagged array.
An array of arrays where each sub-array can have different lengths.
Difference between a 1D array and a 2D array.
A 1D array is linear, while a 2D array represents data in two dimensions.
Fill in the blank: 2D arrays are often used in ___ algorithms.
graph traversal or image processing.
What is an example of a 2D array declaration?
int[][] matrix = { {1, 2}, {3, 4} };
True or false: You can use a for-each loop with a 2D array.
True, because each row can be iterated over like a 1D array.
What will `array[1][2]` access?
The element in the second row and third column of the array.
How to copy a 2D array?
Use nested loops to copy elements, as arrays cannot be directly copied.
Explain a common error with 2D arrays.
Accessing an index out of bounds, leading to an `ArrayIndexOutOfBoundsException`.
Pytania w tym zestawie(18)
1. What does `array.length` return for a 2D array?
2. Which of the following correctly accesses the first element of the second row?
3. Which statement about jagged arrays is true?
4. Which of the following is NOT a valid 2D array initialization?
5. Which method is used to copy elements from a 2D array?
6. How is a 2D array represented in memory?
7. To access the value at the last row and last column in a matrix with 4 rows and 5 columns, what indices are used?
8. What will happen if you try to access `array[2][3]` in a 2D array of size 2x3?
9. Which of the following describes a row-major order?
10. When iterating a 2D array, what is necessary for the inner loop?
11. In Java, how do you declare a 2D array?
12. What does `array[i][j]` represent in a 2D array?
13. True or false: 2D arrays can only hold primitive data types.
14. Which of the following is an example of a jagged array?
15. What will the expression `array.length` return for a two-dimensional array?
16. What happens if you declare a 2D array without assigning a size?
17. How can you represent a chessboard using a 2D array?
18. Which statement is correct about 2D array size?
Powiązane zestawy
Abitur Rekursion
Abitur: Abitur Klassen und Objekte
Wiederholung: Abitur Sortierverfahren
Was ist ein Algorithmus Schritt für Schritt
if und Schleifen Notizen
Test: Binärzahlen
Wiederholung: Funktionen
Schleife Alltag Beispiel Begriffe
Stwórz własny zestaw
Wgraj PDF, wklej notatki lub opisz temat – AI wygeneruje fiszki, quizy i więcej w kilka sekund.

