---
title: "Operator Precedence — AP CSA Definition & Exam Guide"
description: "Operator precedence is Java's rule set for evaluation order: *, /, % before + and -. It drives Unit 1 expression questions, especially with integer division and string concatenation."
canonical: "https://fiveable.me/ap-comp-sci-a/key-terms/operator-precedence"
type: "key-term"
subject: "AP Computer Science A"
unit: "Unit 1"
---

# Operator Precedence — AP CSA Definition & Exam Guide

## Definition

Operator precedence is the set of rules Java uses to decide the order operators are evaluated in a compound expression: multiplication (*), division (/), and remainder (%) are evaluated before addition (+) and subtraction (-), operators of equal precedence go left to right, and parentheses override everything.

## What It Is

Operator precedence is Java's built-in ranking system for [operators](/ap-comp-sci-a/unit-1/expressions-and-assignment-statements/study-guide/01dr6uUPDAn3SjtK2Psr "fv-autolink"). When an [expression](/ap-comp-sci-a/key-terms/expression "fv-autolink") has more than one operator, Java doesn't just read left to right. It evaluates the higher-precedence operators first. In AP CSA, the five arithmetic operators you need (EK 1.3.C.2) split into two tiers. Multiplication `*`, division `/`, and remainder `%` sit on the top tier. Addition `+` and subtraction `-` sit below them. Operators on the same tier are evaluated left to right, and anything in parentheses gets evaluated before the operators outside it.

So `5 + 3 * 2` is 11, not 16, because `3 * 2` happens first. Add parentheses and the story changes. `(5 + 3) * 2` is 16 because parentheses jump the line. The same rules apply when `+` means string [concatenation](/ap-comp-sci-a/unit-1/string-methods/study-guide/SltCtk8JxBIgHcMfG6G4 "fv-autolink"), which is where the exam loves to set traps. In `"Value: " + 5 + 3 * 2`, the `3 * 2` still runs first (it's higher precedence), giving 6. Then the `+` operators go left to right, so `"Value: " + 5` becomes the string `"Value: 5"`, and adding 6 to a string gives `"Value: 56"`.

## Why It Matters

Operator precedence lives in Topic 1.3 (Expressions and Assignment Statements) in [Unit 1](/ap-comp-sci-a/unit-1 "fv-autolink") and directly supports learning objective [AP Comp Sci A](/ap-comp-sci-a "fv-autolink") 1.3.C, which asks you to develop code for arithmetic expressions and determine their results. You literally cannot trace an expression like `x + y * z - x / y` without knowing which operations fire first. It also feeds into AP Comp Sci A 1.3.A and 1.3.B, because output questions mix arithmetic with `System.out.println` and string literals, and the answer depends on whether `+` is doing math or concatenation at each step. This is foundational skill, not trivia. Every expression you write or trace for the rest of the course (loop conditions, array index math, return values) assumes you have precedence down cold.

## Connections

### [Arithmetic expression (Unit 1)](/ap-comp-sci-a/key-terms/arithmetic-expression)

Precedence is the grammar of [arithmetic expressions](/ap-comp-sci-a/key-terms/arithmetic-expression "fv-autolink"). An expression like `x + y * z - x / y` is really three mini-expressions, and precedence tells you which mini-expression Java computes first.

### [Integer division (Unit 1)](/ap-comp-sci-a/key-terms/integer-division)

Exam questions stack these two on purpose. In `7 + 2 * 3 - 7 / 2`, precedence says do `7 / 2` before subtracting, and [integer division](/ap-comp-sci-a/key-terms/integer-division "fv-autolink") says that result is 3, not 3.5. Miss either rule and you get the wrong answer.

### [Remainder operator (Unit 1)](/ap-comp-sci-a/key-terms/remainder-operator)

The `%` operator sits on the SAME precedence tier as `*` and `/`, not below them. So `10 % 3 * 2` evaluates left to right as `(10 % 3) * 2 = 2`, which surprises anyone expecting `%` to wait its turn.

### String literal and concatenation (Unit 1)

When `+` touches a string, it concatenates instead of adding, but precedence rules still apply. That's why `"Value: " + 5 + 3 * 2` prints Value: 56. The `*` runs first, then the `+` operators chain left to right onto the string.

## On the AP Exam

Operator precedence shows up constantly in Unit 1 multiple-choice questions with the stem "What is printed as a result of executing the following code segment?" You'll see paired expressions like `a + b * 2` versus `(a + b) * 2` where the only difference is parentheses, and your job is to produce both outputs correctly. The hardest versions combine three traps in one line: precedence order, integer division truncation, and string concatenation. A typical question asks you to trace `System.out.println(x + y * z - x / y)` with int variables, then a parenthesized variant of the same expression. No released FRQ tests precedence by name, but every FRQ you write assumes you can build expressions that evaluate in the order you intend, so sloppy precedence costs points indirectly through wrong logic.

## operator precedence vs PEMDAS

PEMDAS gets you most of the way, but Java isn't math class. Java has no exponent operator in AP CSA (the E in PEMDAS doesn't apply, you'd use Math.pow instead), and PEMDAS says nothing about `%`, which ranks with `*` and `/`. Also, PEMDAS implies multiplication before division, but in Java they're equal precedence and evaluate left to right. And PEMDAS definitely doesn't cover what happens when `+` hits a string.

## Key Takeaways

- Multiplication, division, and remainder are evaluated before addition and subtraction in Java expressions.
- The remainder operator % has the same precedence as * and /, so `10 % 3 * 2` evaluates left to right and equals 2.
- Operators with equal precedence are evaluated left to right, and parentheses override all precedence rules.
- When + appears next to a string, precedence still applies first, then the remaining + operators concatenate left to right, which is why `"Value: " + 5 + 3 * 2` prints Value: 56.
- Precedence questions often hide integer division inside them, so `7 / 2` inside a bigger expression is 3, not 3.5.
- When tracing an expression, rewrite it with parentheses around the highest-precedence operations first, then work left to right.

## FAQs

### What is operator precedence in AP Computer Science A?

Operator precedence is the set of rules deciding the order Java evaluates operators in a compound expression. In AP CSA, *, /, and % are evaluated before + and -, equal-precedence operators go left to right, and parentheses are evaluated first. It's tested in Topic 1.3 under learning objective AP Comp Sci A 1.3.C.

### Is operator precedence in Java just PEMDAS?

Mostly, but not exactly. Java has no exponent operator (you use Math.pow), the % operator ranks alongside * and /, and multiplication and division are equal precedence evaluated left to right. PEMDAS also can't explain string concatenation behavior, which the exam tests.

### Does % (remainder) have lower precedence than * and / in Java?

No. The [remainder operator](/ap-comp-sci-a/key-terms/remainder-operator "fv-autolink") % has the same precedence as multiplication and division. So `10 % 3 * 2` is evaluated left to right: 10 % 3 is 1, times 2 is 2.

### Why does "Value: " + 5 + 3 * 2 print Value: 56 instead of Value: 11?

Precedence runs 3 * 2 first, giving 6. Then the + operators evaluate left to right. "Value: " + 5 concatenates to the string "Value: 5", and adding 6 to a string concatenates again, giving "Value: 56". To print 11, you'd need parentheses: "Value: " + (5 + 3 * 2).

### How is operator precedence different from integer division?

Precedence decides which operation runs first; integer division decides what a division of two int values produces (just the integer portion of the quotient). Exam questions combine them, so in `7 + 7 / 2`, precedence makes the division happen first and integer division makes it 3, giving 10.

## Related Study Guides

- [1.3 Expressions and Assignment Statements](/ap-comp-sci-a/unit-1/expressions-and-assignment-statements/study-guide/01dr6uUPDAn3SjtK2Psr)

## Structured Data

```json
{"@context":"https://schema.org","@graph":[{"@type":"LearningResource","@id":"https://fiveable.me/ap-comp-sci-a/key-terms/operator-precedence#resource","name":"Operator Precedence — AP CSA Definition & Exam Guide","url":"https://fiveable.me/ap-comp-sci-a/key-terms/operator-precedence","learningResourceType":"Concept explainer","educationalLevel":"AP® / High School","about":{"@id":"https://fiveable.me/ap-comp-sci-a/key-terms/operator-precedence#term"},"audience":{"@type":"EducationalAudience","educationalRole":"student"},"dateModified":"2026-06-11T05:27:18.789Z","isPartOf":{"@type":"Collection","name":"AP Computer Science A Key Terms","url":"https://fiveable.me/ap-comp-sci-a/key-terms"},"publisher":{"@type":"Organization","name":"Fiveable","url":"https://fiveable.me"}},{"@type":"DefinedTerm","@id":"https://fiveable.me/ap-comp-sci-a/key-terms/operator-precedence#term","name":"operator precedence","description":"Operator precedence is the set of rules Java uses to decide the order operators are evaluated in a compound expression: multiplication (*), division (/), and remainder (%) are evaluated before addition (+) and subtraction (-), operators of equal precedence go left to right, and parentheses override everything.","url":"https://fiveable.me/ap-comp-sci-a/key-terms/operator-precedence","inDefinedTermSet":{"@type":"DefinedTermSet","name":"AP Computer Science A Key Terms","url":"https://fiveable.me/ap-comp-sci-a/key-terms"}},{"@type":"FAQPage","mainEntity":[{"@type":"Question","name":"What is operator precedence in AP Computer Science A?","acceptedAnswer":{"@type":"Answer","text":"Operator precedence is the set of rules deciding the order Java evaluates operators in a compound expression. In AP CSA, *, /, and % are evaluated before + and -, equal-precedence operators go left to right, and parentheses are evaluated first. It's tested in Topic 1.3 under learning objective AP Comp Sci A 1.3.C."}},{"@type":"Question","name":"Is operator precedence in Java just PEMDAS?","acceptedAnswer":{"@type":"Answer","text":"Mostly, but not exactly. Java has no exponent operator (you use Math.pow), the % operator ranks alongside * and /, and multiplication and division are equal precedence evaluated left to right. PEMDAS also can't explain string concatenation behavior, which the exam tests."}},{"@type":"Question","name":"Does % (remainder) have lower precedence than * and / in Java?","acceptedAnswer":{"@type":"Answer","text":"No. The [remainder operator](/ap-comp-sci-a/key-terms/remainder-operator \"fv-autolink\") % has the same precedence as multiplication and division. So `10 % 3 * 2` is evaluated left to right: 10 % 3 is 1, times 2 is 2."}},{"@type":"Question","name":"Why does \"Value: \" + 5 + 3 * 2 print Value: 56 instead of Value: 11?","acceptedAnswer":{"@type":"Answer","text":"Precedence runs 3 * 2 first, giving 6. Then the + operators evaluate left to right. \"Value: \" + 5 concatenates to the string \"Value: 5\", and adding 6 to a string concatenates again, giving \"Value: 56\". To print 11, you'd need parentheses: \"Value: \" + (5 + 3 * 2)."}},{"@type":"Question","name":"How is operator precedence different from integer division?","acceptedAnswer":{"@type":"Answer","text":"Precedence decides which operation runs first; integer division decides what a division of two int values produces (just the integer portion of the quotient). Exam questions combine them, so in `7 + 7 / 2`, precedence makes the division happen first and integer division makes it 3, giving 10."}}]},{"@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"AP Computer Science A","item":"https://fiveable.me/ap-comp-sci-a"},{"@type":"ListItem","position":2,"name":"Key Terms","item":"https://fiveable.me/ap-comp-sci-a/key-terms"},{"@type":"ListItem","position":3,"name":"Unit 1","item":"https://fiveable.me/ap-comp-sci-a/unit-1"},{"@type":"ListItem","position":4,"name":"operator precedence"}]}]}
```
