Question Bank · Unit 4
AP® Computer Science A Data Collections Practice Questions
Work through AP Computer Science A practice questions on Data Collections, then check each answer against a worked solution.
Free · no sign-up
Open questions need no account. Sign up or log in to open the rest.
All 1,222
Multiple choice 1,079
Free response 143
What does the following method return for input [[1,2],[3,4],[5,6]]? public static int colSum(int[][] m, int…
Sign up now. It's free!
See the full question with its answer and worked solution.
// Assume: File f = new File("data.txt"); // File contains space-separated integers…
Sign up now. It's free!
See the full question with its answer and worked solution.
An ArrayList<Integer> named scores contains [85, 92, 78, 96,…
Sign up now. It's free!
See the full question with its answer and worked solution.
Question 914
Free response
Arraylists
Consider the following incomplete class definition for a grade book: public class StudentGradeBook { private ArrayList<Integer> grades; // values 0-100 public…
Sign up now. It's free!
See the full question with its answer and worked solution.
Question 915
Free response
2D Arrays
A grayscale image can be represented as a 2D array of integers, where each value is a pixel intensity from 0 (black) to 255 (white). Consider the following…
Sign up now. It's free!
See the full question with its answer and worked solution.
An ArrayList<Integer> named list contains [2, 4, 6, 8, 10]. The following loop runs: for (int i = 0; i…
Sign up now. It's free!
See the full question with its answer and worked solution.
Consider the following code that processes a 2D array: int[][] g = {{1,2,3},{4,5,6},{7,8,9}}; int total = 0; for…
Sign up now. It's free!
See the full question with its answer and worked solution.
Consider a method that takes an ArrayList<String> and returns a new ArrayList…
Sign up now. It's free!
See the full question with its answer and worked solution.
Question 919
Multiple choice
Arrays
What is the output of the following code? int[] arr = {3, 1, 4, 1, 5, 9, 2, 6}; int count = 0; for…
Sign up now. It's free!
See the full question with its answer and worked solution.
A method receives a 2D integer array and returns true…
Sign up now. It's free!
See the full question with its answer and worked solution.
Page 92 of 123
Get your FRQs graded in the Student Portal
In the Verityprep Student Portal, answer the FRQs of AP practice and past exams by typing or uploading a photo. A teacher grades them with that year's official College Board scoring guidelines and gives you an estimated 1–5 score.
Join Verityprep now
AP® and Advanced Placement® are registered trademarks of the College Board, which is not affiliated with, and does not endorse, Verityprep. Names are used for identification purposes only.