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.

Subtopic: Iteration Clear filter

Questions 131–140 of 383
  1. 131
  2. 132
  3. 133
  4. 134
  5. 135
  6. 136
  7. 137
  8. 138
  9. 139
  10. 140

Question 131

Multiple choice Iteration
Consider the following code segment. What is the final value of product? int…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 132

Multiple choice Iteration
A method is intended to return the largest digit in an…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 133

Multiple choice Iteration
What is the output of this code segment? int a = 3, b = 7;…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 134

Multiple choice Iteration
What is the value of result after the following executes? String result = "";…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 135

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 136

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 137

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 138

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 139

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 140

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 131 of 383
Page 14 of 39