Verityprep
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.

Questions 1,041–1,050 of 1,222
  1. 1041
  2. 1042
  3. 1043
  4. 1044
  5. 1045
  6. 1046
  7. 1047
  8. 1048
  9. 1049
  10. 1050

Question 1041

Multiple choice Using Text Files
A text file contains two lines: hello world What is printed? int count = 0; while…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 1042

Multiple choice Using Text Files
A text file contains: hi hello hey. What is printed? int total = 0; while…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 1043

Multiple choice Using Text Files
A text file contains: 5 1 8 3. What is printed? int max = sc.nextInt(); int second = sc.nextInt(); if (second > max) { int temp = max; max = second; second =…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 1044

Multiple choice Using Text Files
A text file contains: true 7 3. What is printed? boolean flag = sc.nextBoolean(); int a = sc.nextInt(); int…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 1045

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 1046

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 1047

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 1048

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 1049

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 1050

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 1,041 of 1,222
Page 105 of 123