Unit 02

Selection and Iteration

Build Magpie — a chatbot that reads what a person typed and answers it — and in doing so learn the two things that turn a list of instructions into a program that responds to the world: decisions, and repetition.

25–35% of the AP Exam~29–31 CED periods~15–17 blocks here12 topics

Computer Science in Java · members' unit

Selection and Iteration is behind a locked door

Units in Computer Science in Java are for people taking the course. Getting in takes a link or a key — signing in on its own doesn't do it.

What's in this unit · 34 min read

  1. The project · Magpie
  2. 2.1 · Algorithms That Decide and Repeat
  3. 2.2 · Boolean expressions
  4. 2.3 · if Statements
  5. 2.4 · Nested if Statements
  6. 2.5 · Compound Boolean expressions
  7. 2.6 · Equivalent Expressions and Comparing Objects
  8. 2.7 · while Loops
  9. 2.8 · for Loops
  10. 2.9 · Standard Loop Algorithms
  11. 2.10 · Standard String Algorithms
  12. 2.11 · Nested iteration
  13. 2.12 · Counting How Often Code Runs
  14. Finishing Magpie
  15. Where this goes next

39 quick checksannotated specimenstepperloop tracerchatbot sandboxtruth tables+2 more

1 Sign in

With your school Google account. This is how your work reaches the gradebook — it doesn't open the unit by itself.

2 Get in

Open the class link your teacher posted — that's the usual way, and it enrolls you on the spot. Or paste an access key if you were handed one.

Or buy it

Reading on your own, with no class? The course can be yours.

A key unlocks this browser and keeps your progress here; signing in keeps it with you across devices. Either way the key itself is only ever checked as a hash. Manage all of this on your account, read what signing in stores, or go back to Computer Science in Java.

Sources

  • College Board — AP Computer Science A Course and Exam Description, Effective Fall 2025
  • Laurie White — Magpie Lab (AP Computer Science A lab series)