AP Computer Science A Flashcards: 2D Array Creation and Access
Written by AP Content Team, Verified for 2026 AP Exams, Last updated: May 2026
Review key ideas with interactive flashcards. This set includes 10 cards to help you master important concepts.
Can the size of a 2D array be changed after it is created?
No, the size of a 2D array is established at the time of creation and cannot be changed.
Card 1 of 10
All Flashcards (10)
Can the size of a 2D array be changed after it is created?
No, the size of a 2D array is established at the time of creation and cannot be changed.
How do you find the number of rows in a 2D array?
The number of rows can be accessed through the `length` attribute of the 2D array itself (e.g., `myArray.length`).
Write the Java code to declare and create a 4x5 2D array of integers named `scores`.
The code would be: `int[][] scores = new int[4][5];`
How do you find the number of columns in a 2D array?
The number of columns can be accessed through the `length` attribute of one of the inner arrays (e.g., `myArray[0].length`).
What types of data can be stored in a 2D array?
2D arrays are versatile and can store either primitive data (like int, double) or object reference data (like String).
What is the syntax for accessing an element in a 2D array?
The square brackets `[row][col]` are used to access an element, where the first index represents the row and the second represents the column.
What is a two-dimensional (2D) array?
A 2D array is a data structure used to represent collections of related data, stored as an array of arrays.
In the syntax `[row][col]`, which index comes first?
The first index is always used for the rows, and the second index is used for the columns.
How would you access the element in the first row and third column of a 2D array named `grid`?
You would use the expression `grid[0][2]` to access that specific element.
Given `double[][] data = new double[10][20];`, what value does `data.length` return?
The expression `data.length` returns the number of rows, which is 10.