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.
Question 1092
Question 1093
n is outside the range 5 through 12, inclusive?Main Solution
Answer
Answer: B. Values outside the inclusive interval [5, 12] are those that are either less than 5 or greater than 12.
Answer: Correct: B
A
n < 5 && n > 12
B
n < 5 || n > 12
C
n <= 5 || n >= 12
D
!(n < 5 || n > 12)
Answer images
Question 1094
Question 1095
Question 1096
Question 1097
Question 1098
public static int process(int n)
{
int count = 0;
while (n >= 10)
{
if (n % 2 == 0)
n = n / 2;
else
n = n - 1;
count++;
}
return count;
}
process(19) ?Main Solution
Answer
Answer: A. Since 19 is odd, it becomes 18. Then 18 is even, so it becomes 9. At that point the loop stops because 9 < 10. The method returns 2.
Answer: Correct: A
A
2
B
3
C
1
D
4
Answer images
Question 1099
AP® and Advanced Placement® are registered trademarks of the College Board, which is not affiliated with, and does not endorse, Verityprep. Names are used for identification purposes only.

