Skip to main content
The new Teacher Workspace is here. Your first 3 assignments are free. Try it →
A colleague sent you $30 off Fiveable. Get the annual plan for $99 →

Primitive Types in AP Computer Science A

In AP Computer Science A, primitive types are Java's built-in data types that store simple values directly. The course uses three of them: int (integers), double (real numbers), and boolean (true or false). This sets them apart from reference types, which store references to objects.

Verified for the 2027 AP Computer Science A exam•Last updated October 2026

What are Primitive Types?

A data type is a set of values plus the operations you can do on those values (EK 1.2.A.1). Java sorts every data type into one of two categories, primitive or reference. Primitive types are the built-in basics. In AP CSA you only work with three of them (EK 1.2.B.1):

  • int holds an integer, like 42 or -7
  • double holds a real number, like 3.14
  • boolean holds either true or false

Think of a primitive variable as a box that holds the actual value itself. A reference variable holds an address that points to an object stored somewhere else. That one difference explains a lot of exam behavior.

Java has five other primitive types (long, short, byte, float, and char). They are explicitly outside the scope of the AP course and exam, so if char shows up in your textbook, don't sweat it for the test. Also note that String is not primitive. It's a reference type, even though it feels basic.

Why Primitive Types matter in AP® Computer Science A

Primitive types are the foundation of Unit 1: Using Objects and Methods, starting in Topic 1.2 (Variables and Primitive Data Types). There they support AP Comp Sci A 1.2.A (picking the right data type category for a specification) and AP Comp Sci A 1.2.B (declaring variables for numbers and Boolean values).

They come back right away in Topic 1.5 (Casting and Ranges of Variables). AP Comp Sci A 1.5.A asks you to cast between int and double. AP Comp Sci A 1.5.B covers integer overflow, and AP Comp Sci A 1.5.C covers round-off error with double. Every one of those ideas exists because primitives are stored in a fixed amount of memory.

Then in Unit 2: Selection and Iteration, Topic 2.2 (Boolean Expressions) and AP Comp Sci A 2.2.A depend on knowing that == compares actual values for primitives. Every if statement and loop condition you write after that runs on boolean values.

How Primitive Types connect across the course

Reference Types and Data Type Categories (Unit 1)

Primitive and reference are the two halves of Java's type system (EK 1.2.A.1). Anything that isn't int, double, or boolean in this course is a reference type used to build objects, like String. Once you can sort a type into the right bucket, the rest of Unit 1's object material makes much more sense.

Casting with (int) and (double) (Unit 1)

Casting is how you move a value from one primitive type to another. (int) 7.9 gives 7 because the decimal part is chopped off, not rounded (EK 1.5.A.2). Going the other way happens automatically, since Java widens an int to a double in mixed expressions like 5 / 2.0 (EK 1.5.A.3).

Integer Overflow and Round-off Error (Unit 1)

An int lives in exactly 4 bytes, so it has a hard ceiling (Integer.MAX_VALUE) and floor (Integer.MIN_VALUE). Push past the ceiling and the value wraps around to something wrong but still in range (EK 1.5.B.3). A double has a similar memory limit, which is why it can produce tiny round-off errors (EK 1.5.C.1). These limits come from how primitives are stored, not from bugs in your logic.

== and Boolean Expressions (Unit 2)

Relational operators like <, >=, and == always produce a boolean, which is a primitive (EK 2.2.A.3). For primitives, == checks whether the two values match. For reference types, it checks whether two variables point to the same object (EK 2.2.A.1). Knowing which kind of type you're comparing tells you what == actually means.

Are Primitive Types on the AP® Computer Science A exam?

On the multiple-choice section, primitive types show up in a few predictable ways.

  • Pick the type. A stem describes data and asks for the right declaration. A test score is an int, a GPA is a double, and whether someone passed is a boolean. Some questions instead ask which category fits a true/false value. That answer is primitive, specifically boolean.
  • Spot the reference type. A question may list several types and ask which one is a reference type. String is the classic correct answer.
  • Trace the value. You get a short expression with casts or mixed int/double math and have to determine the result. Integer division (7 / 2 is 3), truncation from (int), and the (int)(x + 0.5) rounding trick all come up here.
  • Predict overflow or comparison results. Expect to explain what happens when an int passes Integer.MAX_VALUE, or what a relational expression evaluates to.

No released FRQ has used the phrase "primitive types" verbatim. Still, every FRQ makes you declare int, double, and boolean variables correctly and write Boolean conditions. Getting these types right is part of earning points on every free-response question.

Primitive Types vs Reference Types

A primitive variable stores the value itself. int x = 5; puts 5 right in the box. A reference variable stores a reference (think address) that points to an object, like a String. This matters most with ==. For primitives, == compares the actual values. For reference types, it compares whether the two references point to the same object, not whether the contents match. Primitive type names are lowercase (int, double, boolean), while class names like String start with a capital letter. That's a handy clue on the exam.

Key things to remember about Primitive Types

  • The only three primitive types tested on the AP CSA exam are int, double, and boolean.

  • A primitive variable holds its actual value, while a reference variable holds a reference to an object.

  • String is a reference type, not a primitive type, even though it is used constantly.

  • Casting a double to an int truncates the decimal part, so (int) 7.9 evaluates to 7.

  • An int is stored in 4 bytes, so going past Integer.MAX_VALUE causes integer overflow instead of an error message.

  • With primitive types, == compares the actual values, and every relational expression evaluates to a boolean.

Frequently asked questions about Primitive Types

What are primitive types in AP Computer Science A?

Primitive types are Java's built-in data types that store simple values directly. AP CSA uses exactly three of them: int for integers, double for real numbers, and boolean for true or false.

Is String a primitive type in Java?

No. String is a reference type because it defines objects. A common exam question asks you to pick the reference type from a list, and String is usually the answer.

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

A primitive variable stores the value itself, while a reference variable stores a reference to an object. That's why == compares actual values for primitives but compares object references for reference types (EK 2.2.A.1).

Is char on the AP CSA exam?

No. The CED excludes long, short, byte, float, and char. You only need int, double, and boolean for the exam.

Does casting a double to an int round the number?

No, it truncates. (int) 3.99 gives 3, not 4. To round a non-negative double to the nearest integer, use (int)(x + 0.5), and for a negative number use (int)(x - 0.5) (EK 1.5.A.4).