AP CSA · Unit 1
Sort real-world data, explore casting, learn the vocabulary, understand %, then prove it with 20 arithmetic questions.
Activity 1 · 30-Second Sprint
The value is hidden. Pick the primitive type before time runs out — get it right and it flashes by fast, get it wrong and it holds for two seconds so you can study it.
You solved 0 case files.
Reference
Java has exactly eight primitives. Everything else you'll ever use — String, arrays, ArrayList, any object — is a reference type, not a primitive.
String is not on this list of eight.
Widening & Narrowing
Going from int → double is automatic and safe. Going from double → int needs an explicit cast, and it costs you information.
Every int fits inside a double, so Java converts it automatically. No cast, nothing lost.
Java tacks on .0 and stops — the value doesn't change, only the box it lives in gets bigger.
A double can hold values int can't, so you must force the cast — and Java throws information away to make it fit.
(int) always truncates toward zero — it doesn't round. That's why line 2 gives 9, not 10. Line 3 needs its own (int) because Math.round(double) actually returns a long.
Vocabulary
Tap a card to flip it. Read the term, guess the definition, then check yourself.
One More Operator
% is the modulus (or "mod") operator. It doesn't divide — it tells you the remainder left over after division. 17 % 5 asks "how many are left over after fitting as many 5s as possible into 17?" 5 fits three times (15), leaving 2. So 17 % 5 is 2.
It's one of the most useful tools in programming for anything that wraps around or repeats in a cycle: checking even/odd, cycling through a list, formatting a clock, and more.
10 % 3 → 13 fits into 10 three times (9), 1 left over.n % 2 == 0Classic even check — if there's nothing left over after dividing by 2, it's even.(hour + 1) % 12Clock math — after 11, wrap back around to 0.-7 % 3 → -1Java keeps the sign of the first number — negatives can trip you up!Activity 2 · Graded
Every question is visible at once. Answer in any order, as many times as you need — a field turns green the moment it's right. Get all 20 green to earn your certificate below.