The AP Computer Science A exam is a college-level test administered by the College Board. Scoring a 3 or higher (on a 1-5 scale) can earn you college credit at thousands of universities, saving you time and tuition money. Over 3 million students take AP exams each year.
Our AP Computer Science A Practice Set
This fixed practice set contains 40 multiple-choice questions. Use the answer explanations and topic report to identify areas for further study. It does not reproduce every official exam section, response format, or adaptive behavior.
What to Expect
Answer 40 multiple-choice questions with a 60-minute practice timer.
Review the answer explanation for each question after completion.
Use your percent correct and topic report as study feedback, not an official score or a prediction.
Save or print your score report.
This product does not grade essays or spoken responses. Audio is available only on questions with a playback control; some comprehension exercises use written passages.
Try a Sample Question
AP Computer Science A — Sample
Consider the following Java code segment:
int totalPoints = 25;
int numberOfAttempts = 4;
double averageScore = totalPoints / numberOfAttempts;
What is the value of the variable `averageScore` after this code segment executes?
Explanation. The correct answer is 6.0. Let's break down the execution step-by-step. First, you declare two integer variables: `totalPoints` with a value of 25 and `numberOfAttempts` with a value of 4. In the third line, you attempt to calculate `averageScore`. Because both `totalPoints` and `numberOfAttempts` are `int` types, the division `totalPoints / numberOfAttempts` performs integer division. Integer division truncates any decimal part, so 25 divided by 4 results in 6. This integer value (6) is then assigned to the `double` variable `averageScore`. When an `int` is assigned to a `double`, it undergoes automatic type promotion, converting the integer 6 into the double value 6.0. Choice A (5.0) is incorrect because 25 divided by 4 is 6, not 5. Choice C (6.25) is incorrect because the division was performed using two integers, resulting in integer division, not floating-point division. To get 6.25, at least one of the operands would need to be a `double` (e.g., `(double)totalPoints / numberOfAttempts`). Choice D (6) is incorrect because while the integer result of the division is 6, the variable `averageScore` is a `double`, so its value is represented with a decimal component as 6.0.
Save with a Pass
Taking more than one test? An All-Access Pass unlocks every practice test with unlimited retakes.