Primitive Types

Primitive types are Java's built-in data types that store a simple value directly in memory rather than a reference to an object. On the AP CSA exam, the three you're responsible for are int (whole numbers), double (decimal numbers), and boolean (true/false).

Verified for the 2027 AP Computer Science A examLast updated June 2026

What are Primitive Types?

A primitive type is the simplest kind of data Java can hold. When you write int score = 95;, the variable score holds the actual value 95, not an address pointing somewhere else. That's the defining feature of primitives. They're values, not objects, so they have no methods you can call on them.

Java has eight primitive types, but AP CSA only tests three: int for whole numbers, double for decimal numbers, and boolean for true/false. (You may see char in your textbook, but it's not in the AP subset.) Two behaviors matter constantly. First, int has limits, from Integer.MIN_VALUE to Integer.MAX_VALUE, and going past them causes overflow. Second, dividing two ints gives an int, so 7 / 2 is 3, not 3.5. That integer division trap shows up everywhere on the exam.

Why Primitive Types matter in AP Computer Science A

Primitive types are literally the name of Unit 1 in AP Computer Science A. Everything else in the course is built on top of them. Variables hold them, operators combine them, boolean expressions control your if statements and loops, and arrays store collections of them. The unit's learning objectives center on declaring variables of the correct type, evaluating arithmetic expressions (including integer division and the modulus operator %), and casting between int and double. If you misread an expression's type, you misread the program. That's why so many multiple-choice questions quietly hinge on whether a value is an int or a double, and why FRQ rubrics dock you for returning the wrong type from a method.

How Primitive Types connect across the course

Variables (Unit 1)

A variable is a named box; the primitive type tells Java what shape the box is. Declaring double gpa versus int gpa decides what can legally go in the box and how arithmetic on it behaves.

Operators (Unit 1)

Operators behave differently depending on the primitive types they're given. The big one is /, which does integer division when both sides are ints, and %, which only makes sense once you understand int arithmetic.

equals() method (Unit 2)

Primitives are compared with == because the values sit directly in memory. Objects like Strings need equals() because == would compare references instead of contents. Knowing which comparison to use is really just knowing primitive versus reference.

Data Types (Units 1-2)

Java splits all data types into two camps, primitives and reference types. Unit 1 lives in the primitive camp; Unit 2 introduces objects and the reference camp, and the contrast between them powers questions for the rest of the course.

Are Primitive Types on the AP Computer Science A exam?

You won't get a question that says "define primitive type." Instead, primitives are the hidden mechanism behind a huge share of multiple-choice questions. Expect to trace expressions like (int) (5.0 / 2) + 3 % 2 and pick the exact value, spot that 7 / 2 evaluates to 3, recognize when casting to double rescues a division, and identify overflow near Integer.MAX_VALUE. On FRQs, the rubric checks that your method signatures use the right type (returning a double average, not an int) and that your boolean expressions actually evaluate to true/false. Sloppy type handling, like comparing Strings with == or letting integer division truncate an average, is one of the most common ways otherwise-correct FRQ solutions lose points.

Primitive Types vs Reference types

A primitive variable stores the value itself; a reference variable stores the memory address of an object. That's why == works on ints and doubles (it compares values) but lies to you on Strings (it compares addresses), forcing you to use equals(). Primitives also have no methods. You can't write x.something() on an int, but you can call methods on any object. If a variable's type starts with a lowercase letter (int, double, boolean), it's primitive; class names like String start uppercase and are reference types.

Key things to remember about Primitive Types

  • AP CSA only tests three primitive types: int for whole numbers, double for decimals, and boolean for true/false.

  • Primitive variables store the actual value in memory, while reference variables store an address pointing to an object.

  • Dividing two ints performs integer division, so 7 / 2 equals 3, and you need a double or a cast to get 3.5.

  • Compare primitives with == but compare objects like Strings with equals(), because == on objects checks references, not contents.

  • An int can only hold values between Integer.MIN_VALUE and Integer.MAX_VALUE, and exceeding those limits causes overflow.

  • Casting with (int) truncates toward zero, so (int) 3.9 is 3, a detail multiple-choice questions love to test.

Frequently asked questions about Primitive Types

What are primitive types in AP Computer Science A?

They're Java's built-in value types that store data directly rather than referencing an object. The AP exam covers three: int, double, and boolean, all introduced in Unit 1.

Is char a primitive type on the AP CSA exam?

Java has eight primitives including char, but the AP Java subset only tests int, double, and boolean. You won't be required to use char on the exam, though you may see it in class.

Is String a primitive type in Java?

No. String is a class, which makes it a reference type. That's exactly why you compare Strings with equals() instead of ==, and why Strings have methods like substring() while an int has none.

Why does 7 / 2 equal 3 in Java instead of 3.5?

Because both operands are ints, Java performs integer division and throws away the decimal part. To get 3.5, make at least one operand a double, like 7.0 / 2 or (double) 7 / 2.

What's the difference between primitive types and reference types?

A primitive variable holds the value itself (like the int 42), while a reference variable holds the memory address of an object (like a String). This is why == compares values for primitives but compares addresses for objects.