Verityprep
Question Bank

AP® Computer Science A Multiple Choice Questions

Work through AP Computer Science A multiple-choice questions unit by unit, 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 2,621–2,630 of 2,811
  1. 2621
  2. 2622
  3. 2623
  4. 2624
  5. 2625
  6. 2626
  7. 2627
  8. 2628
  9. 2629
  10. 2630

Question 2621

Multiple choice Unit 4: Data Collections
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.

Question 2622

Multiple choice Unit 4: Data Collections
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.

Question 2623

Multiple choice Unit 4: Data Collections
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.

Question 2624

Multiple choice Unit 4: Data Collections
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.

Question 2625

Multiple choice Unit 4: Data Collections
public static int readNumber() throws Exception { Scanner file = new Scanner(new File("missing.txt")); return…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 2626

Multiple choice Unit 4: Data Collections
public static int count() throws Exception { Scanner file = new Scanner(new File("data.txt")); int count = 0; while (file.hasNextInt())…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 2627

Multiple choice Unit 4: Data Collections
Consider the following method: public static int recur(int n) { if (n <= 1) return…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 2628

Multiple choice Unit 4: Data Collections
What is printed when the following main method is executed? public class Searcher { private int[] arr = {1, 3, 5, 8, 9}; public int mystery(int low, int high,…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 2629

Multiple choice Unit 4: Data Collections
A text file contains a single line: 42. What is printed by the following code? Assume sc is a properly constructed Scanner reading that file.
int x = sc.nextInt();
sc.close();
System.out.println(x + 8);
Pick an answer, then check it. The solution opens in a window.

Question 2630

Multiple choice Unit 4: Data Collections
A text file contains a single line: Hello World. What is printed?
String s = sc.nextLine();
sc.close();
System.out.println(s.length());
Pick an answer, then check it. The solution opens in a window.
Question 2,621 of 2,811
Page 263 of 282