Verityprep
Question Bank · Unit 4

AP® Computer Science A Data Collections Multiple Choice Questions

Work through AP Computer Science A multiple-choice 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.

Subtopic: Using Text Files Clear filter

Questions 121–130 of 181
  1. 121
  2. 122
  3. 123
  4. 124
  5. 125
  6. 126
  7. 127
  8. 128
  9. 129
  10. 130

Question 121

Multiple choice Using Text Files
A text file contains: 2 -3 5 -1 4. What is printed? int pos = 0; int neg = 0; while (sc.hasNext()) { int n =…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 122

Multiple choice Using Text Files
A text file contains: 1 2 3 4 5 6. The code reads every other value, skipping alternating tokens. What is printed? int sum =…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 123

Multiple choice Using Text Files
A text file contains: apple,banana,cherry. What is printed? String line =…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 124

Multiple choice Using Text Files
A text file contains: one:two:three:four. What is printed? String line =…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 125

Multiple choice Using Text Files
A text file contains: 5,10,15. What is printed? String line = sc.nextLine(); sc.close(); String[] parts =…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 126

Multiple choice Using Text Files
A text file contains: hello world from java. What is printed? String line = sc.nextLine();…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 127

Multiple choice Using Text Files
A text file contains two lines: Name,Score Alice,95 The first line is a header. What is printed? sc.nextLine(); // skip header…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 128

Multiple choice Using Text Files
A text file contains: 2.5-3.5-4.0. What is printed? String line = sc.nextLine(); sc.close(); String[] parts =…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 129

Multiple choice Using Text Files
A text file contains: 10,20,30,40,50. What is printed? String line = sc.nextLine();…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 130

Multiple choice Using Text Files
A text file contains two lines: 1,2,3 4,5,6 What is printed? int sum = 0; while (sc.hasNext()) { String line =…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 121 of 181
Page 13 of 19