AP Computer Science A 50 Flashcards Intermediate 100% Free

AP Computer Science A:: Arraylist

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

Curriculum Overview

Comprehensive, high-yield AP Computer Science A study deck focusing on Arraylist. Features 50 rigorous, curriculum-aligned flashcards designed for intermediate-level mastery. Core concepts covered include Arraylist, 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

This Unit INDEX Java's String Integer Science Computer Removing ArrayList

Sample Flashcard Questions & Answers

Showing 8 of 50 cards
Question #1 Active Recall

What is the KEY ADVANTAGE of an \(ArrayList\) over a regular array?

- **A)** ArrayLists are always faster than arrays for every operation
- **B)** An \(ArrayList\) always uses less memory than an array
- **C)** An \(ArrayList\) can store primitive types directly, unlike arrays
- **D)** An \(ArrayList\) can DYNAMICALLY grow or shrink in size as elements are added or removed, unlike a regular array, which has a FIXED size once created

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

This flexible sizing is the defining practical advantage of \(ArrayList\) over a fixed-size array, especially useful when the number of elements isn't known in advance.
Question #2 Active Recall

Which line of code correctly declares and creates an empty \(ArrayList\) meant to hold \(String\) objects?

- **A)** \(ArrayList\textless String\textgreater\ list\ =\ new\ ArrayList\textless String\textgreater();\)
- **B)** \(ArrayList\ list\ =\ new\ String[10];\)
- **C)** \(ArrayList\textless String\textgreater\ list\ =\ new\ String();\)
- **D)** \(String\ list\ =\ new\ ArrayList();\)

Answer & Explanation:
**Answer: A)**

The angle-bracket syntax \(\textless String\textgreater\) specifies the ArrayList's element type (generics), and \(new\ ArrayList\textless\textgreater()\) creates an empty instance.
Question #3 Active Recall

Why can an \(ArrayList\) NOT be declared to hold primitive types directly, such as \(ArrayList\textless int\textgreater\)?

- **A)** ArrayLists cannot store numeric data of any kind
- **B)** \(ArrayList\textless int\textgreater\) is perfectly valid Java syntax with no issues
- **C)** Java's generic types (like \(ArrayList\)) can only work with OBJECT/reference types, not primitives -- so a WRAPPER CLASS (like \(Integer\) for \(int\)) must be used instead: \(ArrayList\textless Integer\textgreater\)
- **D)** This restriction only applies to \(double\), never to \(int\)

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

This is exactly why wrapper classes (introduced in Unit 2) matter: Java's generics require an object type, so primitives must be 'wrapped' to be stored in an \(ArrayList\).
Question #4 Active Recall

What does \(list.add("apple")\) do when called on an \(ArrayList\textless String\textgreater\ list\)?

- **A)** It removes "apple" from the list
- **B)** It replaces the list's ENTIRE contents with just "apple"
- **C)** It appends "apple" to the END of the list, increasing the list's size by 1
- **D)** It checks whether "apple" is already in the list, without modifying it

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

The single-argument \(add(element)\) method appends the given element to the end of the list.
Question #5 Active Recall

What does \(list.add(0,\ "apple")\) do, using the TWO-argument version of \(add\)?

- **A)** It appends "apple" to the end of the list, ignoring the index argument entirely
- **B)** It replaces whatever was previously at index 0 with "apple", without shifting anything
- **C)** It INSERTS "apple" at INDEX 0 (the beginning of the list), shifting all existing elements one position to the RIGHT (each existing element's index increases by 1)
- **D)** It removes the element currently at index 0

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

The two-argument \(add(index, element)\) inserts at a specific position, shifting all later elements to make room -- a key behavioral difference from a plain array, which cannot shift elements automatically.
Question #6 Active Recall

What does \(list.get(2)\) return for an \(ArrayList\textless String\textgreater\)?

- **A)** The element at the very END of the list, regardless of size
- **B)** The element currently stored at INDEX 2 (the third element, using zero-based indexing, just like arrays)
- **C)** It removes and returns the element at index 2
- **D)** The total number of elements in the list

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

\(get(index)\) reads (without removing) the element at the specified zero-based index, analogous to \(arr[index]\) for arrays.
Question #7 Active Recall

What does \(list.set(2,\ "banana")\) do?

- **A)** It appends "banana" to the end of the list
- **B)** It removes the element at index 2 without replacing it
- **C)** It REPLACES the element currently at index 2 with "banana", WITHOUT changing the list's overall size
- **D)** It INSERTS "banana" at index 2, shifting later elements to the right (like \(add\))

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

\(set(index, element)\) OVERWRITES an existing element in place -- unlike \(add(index, element)\), it does NOT shift other elements or change the list's size.
Question #8 Active Recall

What is the crucial difference in BEHAVIOR between \(list.set(index,\ value)\) and \(list.add(index,\ value)\)?

- **A)** \(set\) always increases the list's size, while \(add\) never does
- **B)** \(set\) REPLACES an existing element in place (size stays the same), while \(add\) INSERTS a new element and SHIFTS all subsequent elements over (size increases by 1)
- **C)** \(add\) can only be used to remove elements, never to insert them
- **D)** \(set\) and \(add\) always behave identically

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

Confusing \(set\) and the two-argument \(add\) is a common beginner mistake -- their effects on the list's size are fundamentally different.

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.