Computer Science · AP

AP Computer Science A: Data Structures

ArrayLists, 2D arrays, inheritance, and recursion concepts tested on AP Computer Science A.

35 cards · basic cards · AI-written, checked twice. Edit anything.

Study this set free Get FlashKeepers for iPhone
What is an ArrayList in Java?
A resizable array that can grow or shrink dynamically at runtime
How does an ArrayList differ from a regular array?
ArrayList is resizable and part of the Collections Framework, while arrays have a fixed size set at creation
What method adds an element to an ArrayList?
add()
What method removes an element from an ArrayList by index?
remove()
What method accesses an element in an ArrayList at a specific index?
get()
What import statement is required to use ArrayList?
import java.util.ArrayList;
What does the size() method return for an ArrayList?
The number of elements currently in the ArrayList
What exception is thrown when accessing an invalid ArrayList index?
IndexOutOfBoundsException
What is the time complexity of accessing an ArrayList element by index?
O(1) - constant time
What is a 2D array?
An array of arrays, organized in rows and columns like a table or matrix
How do you declare a 2D array of integers named matrix with 3 rows and 4 columns?
int[][] matrix = new int[3][4];
How do you access the element at row 1, column 2 in a 2D array?
array[1][2]
What does matrix.length return for a 2D array?
The number of rows in the 2D array
What does matrix[0].length return for a 2D array?
The number of columns in the first row
What is a ragged array?
A 2D array where rows can have different numbers of columns

20 more cards in the app