AP Computer Science A 50 Flashcards Intermediate 100% Free

AP Computer Science A:: 2D Array

Created by Chat Robotics Community  ·  Updated 2026-08-31

Curriculum Overview

Comprehensive, high-yield AP Computer Science A study deck focusing on 2D Array. Features 50 rigorous, curriculum-aligned flashcards designed for intermediate-level mastery. Core concepts covered include In Java, key problem-solving heuristics, foundational formulas, and exam-tested application scenarios. Ideal for active recall review, spaced repetition study, and scoring in the top percentile.

Topics & Key Concepts

Java ROWS SAME This FIRST Given OUTER Since COLUMN COLUMNS

Sample Flashcard Questions & Answers

Showing 8 of 50 cards
Question #1 Active Recall

What is a 2D (two-dimensional) ARRAY in Java?

- **A)** An array that can only store exactly 2 elements
- **B)** An array of arrays -- conceptually a grid/table of values organized into ROWS and COLUMNS, accessed using TWO indices
- **C)** A single array that can hold twice as many elements as a normal array
- **D)** A synonym for an \(ArrayList\)

Answer & Explanation:
**Answer: B)**

A 2D array is best understood as a grid of values, implemented in Java as an array where each element is itself another array (a row).
Question #2 Active Recall

Which line of code correctly declares and creates a 2D \(int\) array with 3 rows and 4 columns?

- **A)** \(int[][]\ grid\ =\ new\ int[4][3];\) (dimensions reversed)
- **B)** \(int[3][4]\ grid;\)
- **C)** \(int[]\ grid\ =\ new\ int[3,\ 4];\)
- **D)** \(int[][]\ grid\ =\ new\ int[3][4];\)

Answer & Explanation:
**Answer: D)**

The syntax \(new\ int[rows][cols]\) creates a 2D array with the FIRST bracket specifying the number of rows, and the SECOND specifying the number of columns.
Question #3 Active Recall

Given \(int[][]\ grid\ =\ new\ int[3][4];\), how is a SPECIFIC element accessed, such as the element in row 1, column 2?

- **A)** \(grid[2][1]\) (row and column swapped)
- **B)** \(grid[1,\ 2]\)
- **C)** \(grid(1)(2)\)
- **D)** \(grid[1][2]\)

Answer & Explanation:
**Answer: D)**

2D array elements are accessed with TWO separate bracket pairs: \(grid[row][col]\), with row index first and column index second.
Question #4 Active Recall

What does \(grid.length\) return for a 2D array declared as \(int[][]\ grid\ =\ new\ int[3][4];\)?

- **A)** \(7\), the sum of rows and columns
- **B)** \(4\), the number of columns
- **C)** \(12\), the total number of elements
- **D)** \(3\), the NUMBER OF ROWS (the length of the OUTER array)

Answer & Explanation:
**Answer: D)**

\(grid.length\) gives the length of the OUTER array, which corresponds to the number of ROWS in the 2D array.
Question #5 Active Recall

What does \(grid[0].length\) return for \(int[][]\ grid\ =\ new\ int[3][4];\)?

- **A)** \(3\), the number of rows
- **B)** \(4\), the NUMBER OF COLUMNS (the length of ROW 0, which is itself a 1D array)
- **C)** \(12\), the total number of elements
- **D)** \(0\)

Answer & Explanation:
**Answer: B)**

Since a 2D array is really an array of arrays, \(grid[0]\) IS the first row (a 1D array), so \(grid[0].length\) gives that row's length -- the number of columns.
Question #6 Active Recall

What is the standard NESTED \(for\) loop pattern for visiting EVERY element of a 2D array \(grid\) with \(R\) rows and \(C\) columns?

- **A)** \(for\ (int\ row\ =\ grid.length;\ row\ \textgreater\ 0;\ row++)\ \{\ ...\ \}\)
- **B)** \(for\ (int\ col\ =\ 0;\ col\ \textless\ grid.length;\ col++)\ \{\ for\ (int\ row\ =\ 0;\ row\ \textless\ grid[col].length;\ row++)\ \{\ ...\ \}\ \}\) (row/col loop variables swapped incorrectly)
- **C)** \(for\ (int\ row\ =\ 0;\ row\ \textless\ grid.length;\ row++)\ \{\ for\ (int\ col\ =\ 0;\ col\ \textless\ grid[row].length;\ col++)\ \{\ ...\ grid[row][col]\ ...\ \}\ \}\)
- **D)** \(for\ (int\ row\ =\ 0;\ row\ \textless\ grid.length;\ row++)\ \{\ ...\ grid[row]\ ...\ \}\) (single loop, no inner loop)

Answer & Explanation:
**Answer: C)**

The standard nested-loop traversal uses an OUTER loop for rows and an INNER loop for columns, with the inner loop's bound correctly referencing \(grid[row].length\) (that specific row's own length).
Question #7 Active Recall

What is ROW-MAJOR ORDER, as it applies to traversing a 2D array?

- **A)** Row-major order only applies to 1D arrays, never 2D arrays
- **B)** Visiting elements in a completely random order
- **C)** Visiting all elements of ROW 0 first (left to right), THEN all elements of row 1, then row 2, and so on -- the order naturally produced by the standard nested loop with rows as the OUTER loop
- **D)** Visiting all elements of COLUMN 0 first, then column 1, and so on

Answer & Explanation:
**Answer: C)**

Row-major order (row by row) is the natural, default traversal order produced when rows form the outer loop -- the opposite convention (column by column) is called column-major order.
Question #8 Active Recall

To traverse a 2D array in COLUMN-MAJOR order (visiting all of column 0 first, then column 1, etc.) instead of the default row-major order, what change is needed to the standard nested loop?

- **A)** No change is needed; the standard nested loop already produces column-major order by default
- **B)** Column-major order is impossible to achieve with nested loops
- **C)** SWAP which variable is the OUTER loop and which is the INNER loop -- make the COLUMN index the outer loop and the ROW index the inner loop
- **D)** Simply reverse the direction of the outer loop, keeping row as the outer variable

Answer & Explanation:
**Answer: C)**

Swapping which dimension serves as the outer vs. inner loop variable is exactly what changes the traversal order between row-major and column-major.

Want to study all 50 flashcards with spaced repetition?

Practice with Anki-style scheduling, Hands-Free audio commute mode, and AI Tutor explanations.

Start Studying Full Deck Now

How You Can Study This Deck on Chat Robotics

Anki Spaced Repetition (SRS)

Algorithms schedule review intervals automatically so you retain 90%+ in minimum study time.

Hands-Free Audio Commute Mode

High-fidelity Neural Text-To-Speech reads questions and answers aloud with customizable delay timers.

Built-in AI Tutor Assistant

Stuck on a tricky concept? Click "Ask AI" on any card to receive instant deep-dive step-by-step explanations.

Subdeck & Tag Organization

Organize and filter by topic tags or drill entire subdeck hierarchies sequentially in Subdeck Scheduler.