Increment, Decrement, Shorthand Operators, Precedence, new and Dot in Java (ICSE Class 9)
Updated 18 October 2026 · Fact-checked
++ and -- add or subtract 1: prefix (++a) changes first and then uses the value, postfix (a++) uses the old value and then changes. Shorthand operators such as a += 3 mean a = a + 3, with the whole right side worked out first. When operators mix, higher precedence goes first and equal precedence follows associativity (mostly left to right). The new operator creates an object and the dot operator reaches its members.
Follow the arrows downward: with ++a the variable changes before b receives it, but with a++ b gets the old value 5 first.
Illustration drawn for QuestionBuddy.
Understand Increment, Decrement, Shorthand Operators, Precedence, new and Dot
Increment and decrement. ++ adds 1 and -- subtracts 1.
- Prefix (++a): change first, then use. With a = 5, b = ++a gives b = 6 and a = 6.
- Postfix (a++): use first, then change. With a = 5, b = a++ gives b = 5 and a = 6.
- Written alone as a statement, a++; and ++a; do the same thing.
- To trace a line like c = a++ * b + --a, go strictly left to right and write both the value used and the new value of the variable at each step.
Shorthand (compound) assignment. += -= *= /= %= . The statement a op= b means a = a op (b); the whole right side is calculated first, so x *= 2 + 3 is x = x * (2 + 3). With a compound assignment the left-hand value is picked up before the right side runs.
Counters and accumulators. A counter counts how many times something happens, usually by a fixed step (count++). An accumulator builds a running total by adding varying amounts (sum += x).
Precedence (highest first).
1. brackets, dot, postfix ++ --
2. prefix ++ --, unary + - and !
3. * / %
4. + -
5. < <= > >=
6. == !=
7. &&
8. ||
9. ?:
10. = += -= *= /= %=
Equal operators are done left to right, except unary operators, ?: and assignment, which go right to left. So 100 / 10 / 2 = 5 and 20 - 6 - 4 = 10.
The ternary operator. condition ? value1 : value2 gives value1 if the condition is true, otherwise value2. It can be nested.
The new and dot operators. new creates an object in memory at run time and returns its reference: Scanner sc = new Scanner(System.in);. The dot operator invokes a member of a class or object: sc.nextInt(), Math.sqrt(16), System.out.println().
print() and println(). print() leaves the cursor on the same line; println() moves to the next line afterwards. The + sign joins text with values, and once a String has appeared, the rest of a + chain is joining, not adding: "Sum: " + 4 + 6 prints Sum: 46, but 4 + 6 + " total" prints 10 total.
Neighbouring topics: the types of operators and integer division are on the previous page of this chapter.
Increment, Decrement, Shorthand Operators, Precedence, new and Dot: key facts
- Prefix and postfix
- ++a: change, then use
- a++: use, then change
- alone, both add 1
- The same rule holds for --.
- Shorthand
- a += b means a = a + b
- x -= y + 1 means x = x - (y + 1)
- right side first
- Includes -= /= %= and the multiply form.
- Precedence ladder
- () . postfix
- prefix and unary
- multiply, divide, remainder
- add, subtract
- relational
- == !=
- &&
- ||
- ?:
- assignment
- Brackets override all.
- Joining text
- number + number adds
- once a String appears, + joins
- work left to right
- 4 + 6 + "x" gives 10x.
How to answer Increment, Decrement, Shorthand Operators, Precedence, new and Dot questions
Use this routine for increment and precedence questions.
- 1List every variable with its starting value.
- 2Mark the precedence: postfix, prefix, then * / %, then + -, and so on.
- 3Work left to right; for a++ note the old value then update a, for ++a update a then note the value.
- 4After the statement, write the final value of every changed variable.
- 5For printing, evaluate each part in order and decide whether + adds or joins.
Increment, Decrement, Shorthand Operators, Precedence, new and Dot in real life
The idea, met in an everyday situation. Answer the question in your own words, then compare with the model answer. The one-line hook is what to remember.
Counter and accumulator
Suppose a toll booth program counts the vehicles that pass and also adds up the fee collected; 4 vehicles pay Rs 40, 40, 90 and 40.
What are the counter and the accumulator at the end?
Try it first, then show the solutionSolution
- The counter goes up by 1 per vehicle: 4.
- The accumulator adds each fee: 40 + 40 + 90 + 40 = 210.
Answer: Counter = 4 vehicles and accumulator = Rs 210.
Memory hook: Counters count by one; accumulators add what arrives.
Tricks to remember Increment, Decrement, Shorthand Operators, Precedence, new and Dot
Short memory aids. Say each one aloud once, then use it on a question the same day.
Pre = change first
++a changes before you look; a++ lets you look and then changes.
Use it when: Prefix versus postfix.
Equals goes last
Assignment has the lowest precedence, so everything on its right is solved before storing.
Use it when: Shorthand operators.
Number, number, then text
Numbers add until the first String; after it, everything joins.
Use it when: Output questions with + and strings.
Increment, Decrement, Shorthand Operators, Precedence, new and Dot: solved examples
Ordered from board level to HOTS. Try each one before you open the solution.
Example 1: Shorthand value · 1 mark · MCQBoard level
What is the value of x after:
int x = 20; x -= 2 * 3;
(a) 54 (b) 14 (c) 66 (d) 18
Try it first, then show the solutionSolution
- The right side is 2 * 3 = 6.
- x = 20 - 6 = 14.
Answer: (b) 14
Example 2: Prefix, postfix and decrement together · 3 marks · Short answerHarder board level
Find the values printed:
int a = 6, b = 2;
int c = a++ * b-- + --a;
System.out.println(a + " " + b + " " + c);Try it first, then show the solutionSolution
- a++ gives 6 and a becomes 7; b-- gives 2 and b becomes 1, so the product is 12. (1 mark)
- --a makes a 6 and gives 6, so c = 12 + 6 = 18. (1 mark)
- Final values: a = 6, b = 1, c = 18. (1 mark)
Answer: 6 1 18
Example 3: Precedence with a short-circuit · 3 marks · Short answerHarder board level
Find the output:
int r = 5 + 18 / 4 % 3 * 2 - 7;
boolean s = r == 0 || r++ > 3;
System.out.println(r + " " + s);Try it first, then show the solutionSolution
- 18 / 4 = 4, 4 % 3 = 1, 1 * 2 = 2 (same level, left to right). (1 mark)
- r = 5 + 2 - 7 = 0. (1 mark)
- r == 0 is true so || skips r++; s = true and r stays 0. (1 mark)
Answer: 0 true
Example 4: Case study: the shop bill · 4 marks · Case-basedHOTS / competency
A program keeps a bill and a count of items:
int bill = 500, items = 2;
bill += 120;
items++;
bill -= bill % 100;
items *= 2;
System.out.println(bill + " " + items + " " + bill / items);(i) State bill and items after the first two statements. (1)
(ii) Name the accumulator and the counter. (1)
(iii) Trace the rest and state the output. (2)
Try it first, then show the solutionSolution
- (i) bill = 500 + 120 = 620 and items = 3.
- (ii) bill is the accumulator (it grows by varying amounts); items is the counter (it grows by 1).
- (iii) bill % 100 = 20, so bill = 620 - 20 = 600; items = 3 * 2 = 6; bill / items = 600 / 6 = 100. Output: 600 6 100.
Answer: (i) 620 and 3 (ii) accumulator bill, counter items (iii) 600 6 100
Example 5: Nested ternary · 3 marks · Short answerHarder board level
Find the output:
int n = 14;
String t = n % 2 == 0 ? (n > 10 ? "big even" : "small even") : "odd";
System.out.println(t + " " + (n > 10 ? n / 4 : n * 4));Try it first, then show the solutionSolution
- n % 2 == 0 is true, so the bracket is chosen; n > 10 is true, so t = "big even". (1 mark)
- n > 10 is true, so the second part is n / 4 = 14 / 4 = 3 (integer division). (1 mark)
- The line joins t, a space and 3. (1 mark)
Answer: big even 3
Where students lose marks in Increment, Decrement, Shorthand Operators, Precedence, new and Dot
The slips examiners see most often, and what to write instead.
Mistake: Using the new value for a postfix
Postfix is read as prefix.
Wrong working
b = a++ with a = 5 gives b = 6
Right working
b = a++ with a = 5 gives b = 5, a = 6
Do this: Write "use, then change" next to every a++.
Usually costs: 1 mark
Mistake: Shorthand without brackets
The right side is split.
Wrong working
x = 4; x *= 3 + 2 gives 14
Right working
x = 4; x *= 3 + 2 gives 20
Do this: Rewrite as x = x * (3 + 2) first.
Usually costs: 1 mark
Mistake: Adding after a String has appeared
+ has two meanings.
Wrong working
"Sum: " + 4 + 6 gives Sum: 10
Right working
"Sum: " + 4 + 6 gives Sum: 46
Do this: After the first String, everything joins.
Usually costs: 1 mark
Exam tips
- Dry-run with one column per variable and update it after every operator.
- Use brackets to show the precedence you applied.
- Remember / and % rank with *, not with +.
- Use the words counter and accumulator exactly as defined.
Practice questions on Increment, Decrement, Shorthand Operators, Precedence, new and Dot
Write each answer on paper first. Open the hint only if you are stuck, and the answer only when you have finished.
Q1 · 1 mark · MCQBoard level
Which of these has the highest precedence?
(a) + (b) % (c) && (d) =Hint
Think of the ladder from the top.
Answer
(b) %
Q2 · 2 marks · Very short answerBoard level
Rewrite each with a shorthand operator: (i) s = s - 3; (ii) p = p * (q + 1); (iii) r = r % 5;
Hint
The whole right side stays together.
Answer
(i) s -= 3; (ii) p *= q + 1; (iii) r %= 5;
Q3 · 2 marks · Short answerHarder board level
Find the value of a:
int a = 3; a = a++ + ++a; System.out.println(a);Hint
The first a++ gives 3 and a becomes 4.
Answer
8 (a++ gives 3, a is 4; ++a makes a 5 and gives 5; 3 + 5 = 8)
Q4 · 3 marks · Short answerHarder board level
Find the output:
int k = 8; k -= --k - k--; System.out.println(k);Hint
The old k (8) is kept for the -=.
Answer
8 (the saved k is 8; --k gives 7; k-- gives 7 and k becomes 6; 7 - 7 = 0; k = 8 - 0 = 8)
Q5 · 2 marks · Short answerHOTS / competency
Why does System.out.println("Total: " + 4 + 6); print Total: 46 while System.out.println(4 + 6 + " is total"); prints 10 is total?
Hint
Where does the first String appear?
Answer
In the first, "Total: " is already a String, so 4 and 6 are joined one after the other. In the second, 4 + 6 is calculated first because both are numbers; the String comes after, so 10 is joined to the text.
Test your recall
Answer in your head or on paper first, then open the card. Pulling an answer out of memory makes it stick far better than re-reading.
1.What does a += b mean?Show answer
a = a + b
2.Value used by b = a++ when a is 5?Show answer
5
3.Which operator creates an object?Show answer
new
4.Which operator reaches a member of an object?Show answer
The dot operator.
5.Associativity of assignment?Show answer
Right to left.
6.Does println() move to a new line?Show answer
Yes, after printing.
Increment, Decrement, Shorthand Operators, Precedence, new and Dot: frequently asked questions
Will tricky lines like a++ + ++a be asked?
Yes. Such lines are common in output questions; trace them strictly from left to right.
What is the difference between a counter and an accumulator?
A counter counts events by a fixed step such as 1; an accumulator adds varying values to make a total.
Do I need bitwise operators in Class IX?
No, they are exempted.