Verityprep
Question Bank

AP® Computer Science A Practice Questions

Work through AP Computer Science A practice 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 1,071–1,080 of 3,140
  1. 1071
  2. 1072
  3. 1073
  4. 1074
  5. 1075
  6. 1076
  7. 1077
  8. 1078
  9. 1079
  10. 1080

Question 1071

Multiple choice Unit 2: Selection and Iteration
Which of the following code segments correctly counts the number of vowels in a String s? (Assume lowercase only.) // Segment I int count = 0; for (int i = 0; i…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 1072

Multiple choice Unit 2: Selection and Iteration
Consider the following method that is supposed to check whether a String is a palindrome. public static boolean isPalindrome(String s) { int left = 0, right =…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 1073

Multiple choice Unit 2: Selection and Iteration
What does the following method return when called as mystery(6)? public static int mystery(int…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 1074

Free response Unit 2: Selection and Iteration
A teacher wants to analyze student-submitted text. You will write methods for a TextAnalyzer class. The class has a single instance variable: private String…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 1075

Multiple choice Unit 2: Selection and Iteration
The following code is meant to find the GCD of two positive integers using Euclid's algorithm. Which correctly completes…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 1076

Multiple choice Unit 2: Selection and Iteration
What does the following method return for n = 7? public static boolean check(int n) { if (n < 2)…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 1077

Multiple choice Unit 2: Selection and Iteration
A method with parameter int n must return true if and only if n is a perfect square,…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 1078

Multiple choice Unit 2: Selection and Iteration
What is the output of this code? int a = 2, b = 3, c = 4; if (a < b && b < c) a = b +…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 1079

Multiple choice Unit 2: Selection and Iteration
What is the output of the following code? int x = 100; while (x > 1) { if (x %…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 1080

Multiple choice Unit 2: Selection and Iteration
Consider the following method: public static String build(int n) { String s = ""; for (int i = 1; i <= n; i++) { for…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 1,071 of 3,140
Page 108 of 314