In AP Computer Science A, the + operator performs arithmetic addition when both operands are numeric (int or double) and string concatenation when at least one operand is a String, with expressions evaluated left to right.
The + operator is the one symbol in Java that does two completely different jobs. When both operands are numbers, it adds them, so 3 + 4 gives 7. When at least one operand is a String, it concatenates, gluing the values together into a new String, so "3" + 4 gives "34". Java decides which job to do based on the types of the operands at that moment in the expression.
The part that trips people up is that Java evaluates + left to right, and the meaning can flip mid-expression. Take "Sum: " + 2 + 3. Java hits "Sum: " + 2 first, sees a String, and concatenates to get "Sum: 2". Then "Sum: 2" + 3 concatenates again, producing "Sum: 23". But 2 + 3 + " is the sum" evaluates 2 + 3 first (both numbers, so real addition), giving "5 is the sum". Same operator, same values, different order, different output. If you want addition inside a concatenation, wrap it in parentheses: "Sum: " + (2 + 3) prints Sum: 5.
The + operator lives in two units at once. In Unit 1 (Primitive Types), it's one of the core arithmetic operators you use in expressions with int and double values, where you also have to track int vs. double results. In Unit 2 (Using Objects), it reappears as the String concatenation operator, and the CED expects you to trace mixed expressions where numbers and Strings collide. Because almost every System.out.println() statement on the exam mixes text labels with computed values, you can't read or write output code confidently until the dual behavior of + is automatic. It's a small operator with an outsized presence in MCQ "what is printed?" questions.
Arithmetic operators (Unit 1)
The + operator is one of the five arithmetic operators (+, -, *, /, %), but it's the only one that changes meaning based on type. The other four always do math, while + switches to concatenation the moment a String shows up.
System.out.println() (Unit 1)
Print statements are where + concatenation actually gets used. Nearly every output line you write looks like System.out.println("Count: " + count), so println questions are secretly + operator questions.
Escape Sequence (Unit 2)
Escape sequences like \n and " let you put special characters inside the String literals you're concatenating. Tracing output often means handling both at once, like a + that joins strings and a \n that splits lines.
Comparison operators (Unit 1)
After + builds a value, comparison operators like == and < test it. The type lesson carries over too. Just as + behaves differently for Strings, == compares references for Strings, so you need .equals() instead.
The + operator shows up constantly but almost never as a vocab question. Instead, MCQs hand you a code segment with mixed Strings and numbers and ask "what is printed?" The trap answers come from misreading left-to-right evaluation, like choosing "Sum: 5" when the code actually prints "Sum: 23". On FRQs, you'll use + yourself whenever a method needs to build and return a String, such as assembling a word, a label, or a formatted result. Two habits keep you safe: trace + one pair of operands at a time, and use parentheses when you mean arithmetic inside a concatenation.
These are the two faces of the same operator, and Java picks between them by type, not by what you intended. 1 + 2 + "!" does addition first and prints "3!", while "!" + 1 + 2 concatenates the whole way and prints "!12". If either operand in a given + is a String, that + concatenates. If both are numeric, it adds. Check types pair by pair, left to right, and the answer falls out.
The + operator adds when both operands are numeric and concatenates when at least one operand is a String.
Java evaluates + left to right, so the operator's meaning can switch partway through a single expression.
"Sum: " + 2 + 3 prints "Sum: 23" because the String makes everything after it concatenation, while "Sum: " + (2 + 3) prints "Sum: 5".
Concatenating any primitive with a String converts that value to its String form automatically.
Most println statements on the exam rely on + concatenation, so output-tracing questions are really testing whether you know which job + is doing.
When in doubt, add parentheses around arithmetic inside a concatenation to force addition to happen first.
It's Java's symbol for both arithmetic addition and String concatenation. With two numeric operands it adds (3 + 4 is 7); with at least one String operand it concatenates ("3" + 4 is "34").
Because one operand is a String, Java converts the int 1 to "1" and concatenates, producing "11". The + operator only does math when both operands are numeric.
Yes. That's why 1 + 2 + "!" prints "3!" (addition happens before the String appears) but "!" + 1 + 2 prints "!12" (the String comes first, so every + concatenates).
Subtraction, multiplication, division, and modulus only work on numbers. The + operator is the only arithmetic operator that also works on Strings, where it concatenates instead of computing. Writing "abc" - "a" is a compile-time error, but "abc" + "a" is fine.
Yes, but the result is a String, not a number. "Score: " + 95 gives the String "Score: 95". Java automatically converts the numeric value to its String form during concatenation.