AP® Computer Science A Data Collections Multiple Choice Questions
Work through AP Computer Science A multiple-choice questions on Data Collections, 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.
Multiple choice
Arraylists
Question 1052
Multiple choice
2D Arrays
Question 1053
Multiple choice
Recursion
Question 1054
Multiple choice
Arrays
Question 1055
Multiple choice
Arrays
Question 1056
Multiple choice
Arraylists
Question 1057
Multiple choice
2D Arrays
Question 1058
Multiple choice
Recursion
Consider the following method.
public static int g(int n)
{
if (n == 1)
return 1;
if (n % 2 == 0)
return g(n / 2);
return 1 + g(n - 1);
}
What value is returned by g(12) ?
Pick an answer, then check it. The solution opens in a window.
ACorrect answer
Main Solution
Answer
Answer: A. Since 12 is even, g(12) = g(6). Since 6 is even, g(6) = g(3). Then g(3) = 1 + g(2) = 1 + g(1) = 2.
Answer: Correct: A
A
2
B
3
C
4
D
1
Answer images
Question 1059
Multiple choice
Arrays
Question 1,051 of 1,079
Page 106 of 108
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.

