Verityprep
Question Bank · Unit 2

AP® Computer Science A Selection and Iteration Practice Questions

Work through AP Computer Science A practice questions on Selection and Iteration, 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 291–300 of 740
  1. 291
  2. 292
  3. 293
  4. 294
  5. 295
  6. 296
  7. 297
  8. 298
  9. 299
  10. 300

Question 291

Multiple choice Iteration
What is the value of sum after the following executes? int sum =…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 292

Multiple choice Boolean Expressions
Which of the following boolean…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 293

Multiple choice Iteration
Consider the following code: int count = 0; for (int i = 0; i < 4; i++) { for…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 294

Multiple choice Iteration
What is the output of the following code? int n = 4; for (int i = 1; i <= n; i++)…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 295

Multiple choice 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 296

Multiple choice 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 297

Multiple choice 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 298

Free response 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 299

Multiple choice 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 300

Multiple choice 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 291 of 740
Page 30 of 74