From the free course AP Computer Science A on Lykke
AP Practice 6
A useful computer program can still cause harm when it collects more data than necessary, hides important conditions, or produces results that people cannot reasonably question.
AP Practice 6
A useful computer program can still cause harm when it collects more data than necessary, hides important conditions, or produces results that people cannot reasonably question. This original practice task combines two exam-relevant demands: Analyze Code and Use Computers Responsibly.
Task profile: responsible analysis of a data-collection program
| Feature | Practice target |
|---|---|
| Task type | Original multiple-choice-style questions |
| Primary computational practices | 3. Analyze Code; 5. Use Computers Responsibly |
| Supporting practice | 4. Document Code and Computing Systems |
| Suggested timing | About $12$ minutes for four questions |
| Scoring approach | Select the best answer; justify it with code behavior or an ethical principle |
| Course context | Java, objects, methods, arrays, selection, iteration, and data collection |
The goal is not merely to identify whether the program runs. Strong reasoning must connect what the code does with what the system should be allowed to do. An answer that describes an ethical concern but misreads the code is incomplete; an answer that traces the code perfectly but ignores privacy, fairness, or transparency misses the computing-system issue.
Shared scenario
A school uses the following class to record students’ study-session information. The system is intended to recommend optional review materials.
public class StudyRecord
{
private String studentName;
private int minutes;
private boolean completedSurvey;
public StudyRecord(String name, int time, boolean survey)
{
studentName = name;
minutes = time;
completedSurvey = survey;
}
public boolean shouldRecommend()
{
if (minutes < 20)
{
return true;
}
else if (completedSurvey && minutes < 45)
{
return true;
}
return false;
}
public String getStudentName()
{
return studentName;
}
}
The recommendation rule is a form of selection: different Boolean conditions lead to different results. Notice also that the object stores an identifying value, studentName, even though the recommendation decision depends only on minutes and completedSurvey.
Question 1 — Analyze Code
For a record constructed as follows, what value does shouldRecommend() return?
StudyRecord record =
new StudyRecord("Mina", 30, false);
- A.
true, because $30$ is greater than $20$ - B.
true, because the student has a recorded study session - C.
false, because neither condition in the method is satisfied - D. A compilation error, because
falsecannot be passed to a constructor
Answer: C. The first condition, minutes < 20, is 30 < 20, which is false. The second condition requires both completedSurvey and minutes < 45; although $30 < 45$ is true, completedSurvey is false. The method reaches return false.
Rewarded reasoning — Computational Thinking Practice 3: Analyze Code: trace each condition using the actual stored values. Computational Thinking Practice 4: Document Code and Computing Systems: explain the specific condition that produces the result rather than reporting only the final Boolean value.
Question 2 — Data minimization
Which change best reduces the collection of unnecessary personal information while preserving the behavior of shouldRecommend()?
- A. Replace
studentNamewith a shorter name - B. Remove
studentNameandgetStudentName() - C. Change
studentNamefromprivatetopublic - D. Store both the student’s name and identification number
Answer: B. The recommendation method never uses studentName. Removing it follows data minimization: collect and retain only information needed for the stated purpose. Making the field public increases access; collecting an additional identifier makes the unnecessary-data problem worse.
Rewarded reasoning — Computational Thinking Practice 5: Use Computers Responsibly: identify the privacy consequence and connect it to the program’s purpose. The key distinction is between information available to the system and information required by the algorithm.
Question 3 — Hidden assumptions
Suppose a teacher says, “Every student who studies fewer than $20$ minutes should receive a recommendation.” Which observation is most important?
- A. The program uses a constructor.
- B. The method returns a Boolean value.
- C. Students who study between $20$ and $44$ minutes receive recommendations only if they complete the survey.
- D. The class contains three instance variables.
Answer: C. The program embeds an additional condition that may not be visible in the teacher’s informal statement. A student with $30$ minutes receives different results depending on completedSurvey. This is a transparency issue: people affected by an automated decision need a clear explanation of the conditions that influence it.
Rewarded reasoning — Computational Thinking Practice 4: Document Code and Computing Systems: describe the behavior and the condition producing it. Computational Thinking Practice 5: Use Computers Responsibly: recognize that an unexplained eligibility requirement can create unequal access to recommendations.
Question 4 — Fairness and testing
Which test set would best investigate whether the survey requirement affects students with similar study times?
- A. Records with minutes $= 5$, $10$, and $15$
- B. Records with minutes $= 50$, $60$, and $70$
- C. Pairs of records with the same minutes from $20$ through $44$, differing only in
completedSurvey - D. Records with different names but identical values for all other fields
Answer: C. A controlled comparison changes one relevant input while holding the other relevant input constant. For example, compare (30, true) with (30, false), then repeat for other values in the interval. This reveals whether survey completion changes the recommendation.
Timing and error review
Use approximately $3$ minutes to trace the shared code, $6$ minutes for the four questions, and $3$ minutes to review errors. For every missed question, record three facts: the input values, the exact executed condition, and the computational or ethical principle involved.
A strong review distinguishes code-tracing errors from system-reasoning errors. If you chose A for Question 1, revisit relational operators and Boolean conjunction. If you chose A, C, or D for Question 2, revisit data minimization. If you chose D for Question 4, revisit controlled testing: changing a value that the algorithm does not use cannot reveal the survey requirement.
Retrieval check
Why is removing studentName a design improvement even though the program can run correctly with it? Because correct execution is not the only standard for a computing system: unnecessary personal data increases privacy risk without contributing to the stated recommendation decision.

Source Materials
- AP Computer Science A Course and Exam Description
- AP Computer Science A Course and Exam Description Clarifications and Corrections
- AP Computer Science A Course Overview
- AP Computer Science A Course at a Glance
- AP Computer Science A Course at a Glance Poster
- Adopt AP Computer Science A
- AP Computer Science A
- AP Computer Science A
- AP Computer Science A-AP Students-College Board
- AP Computer Science A Textbook-Code HS
- AP Computer Science A - Code.org
- Guide to the AP Computer Science A Exam- Princeton Review