Primitive types
AP Computer Science A · Unit 1: Basics
Primitive types notes
Fact-checked by a second, independent AI review.
Core ideas about Java primitive types, including their sizes, default behaviors, literals, and common exam questions on choosing, declaring, and casting between them.
- int
- Whole numbers; 32-bit signed; used for counters and indices; typical questions ask for correct type for a value and simple arithmetic.
- double
- Floating-point numbers; 64-bit; used for decimals; questions cover when to use double vs int and basic arithmetic behavior.
- boolean
- True/false values; stored as boolean; used in conditionals and flow control.
- char
- Single Unicode character; 16-bit; questions may involve literals and character arithmetic or escaping.
- byte/short/long/float
- Small/large integer and floating-point variants; tests focus on choosing smallest adequate type, range considerations, and literal suffixes (L, F) where applicable.
Remember it: Remember: in Java, you must tell the computer exactly which type you want (the type is the label on the box).
Exam tip: Markers look for correct type selection, proper use of literals and suffixes, awareness of range/overflow, and correct casting when mixing types; avoid implicit narrowing that loses data.
Syllabus checklist
- Primitive types: core ideas
- Terms and typical exam questions for "Basics" in AP Computer Science A (Java
- College Board)
Practice questions
1. Which data type stores whole numbers in Java?
Answer checked
Show answer
Answer: int. int is used for whole numbers, unlike double (real numbers) and boolean (true/false).
2. A boolean can only be true or false.
Answer checked
Show answer
Answer: True. Booleans have exactly two possible values: true and false.
3. The result of 5 ÷ 2 using int operands is ____.
Answer checked
Show answer
Answer: 2. Integer division discards the remainder, so 5 ÷ 2 equals 2.
4. Which primitive type stores a single Unicode character?
Answer checked
Show answer
Answer: char. char holds one Unicode character.
5. Which primitive type has the smallest range in Java?
Answer checked
Show answer
Answer: byte. byte has the smallest range among the listed primitive types.

Practise primitive types as a game
Hearts, combos, streaks and an AI tutor that explains every answer. Start free.