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
Subtopic: Using Text Files
Clear filter
Assume that info.txt contains the following: Hello World AP CSA Good Bye Consider the following code segment: File file = new File("info.txt"); Scanner scanner…
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.
A file numbers.txt contains one integer per line. Which code segment correctly reads all integers and finds the…
Sign up now. It's free!
See the full question with its answer and worked solution.
Assume the file data.txt contains: 5 7 3 public static int readNumbers() throws Exception { Scanner file = new Scanner(new…
Sign up now. It's free!
See the full question with its answer and worked solution.
Assume the file data.txt contains: apple banana cat public static int countLines() throws Exception { Scanner file = new Scanner(new…
Sign up now. It's free!
See the full question with its answer and worked solution.
Assume the file data.txt contains: dog cat bird public static int totalLength() throws Exception { Scanner file = new Scanner(new File("data.txt"));…
Sign up now. It's free!
See the full question with its answer and worked solution.
Assume the file data.txt contains: 1 2 3 4 5 public static int countNumbers() throws Exception { Scanner file = new Scanner(new…
Sign up now. It's free!
See the full question with its answer and worked solution.
Assume the file data.txt contains: apple banana cat dog fish bird public static int count() throws Exception { Scanner file = new Scanner(new…
Sign up now. It's free!
See the full question with its answer and worked solution.
Assume the file data.txt contains: 4 7 2 9 5 8 public static int count() throws Exception { Scanner file = new Scanner(new…
Sign up now. It's free!
See the full question with its answer and worked solution.
public static int readNumber() throws Exception { Scanner file = new Scanner(new File("data.txt")); return…
Sign up now. It's free!
See the full question with its answer and worked solution.
Page 7 of 19
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.