Skip to content
Computer ApplicationsICSE Class 10 · Chapter 4

Operators in Java ICSE Class 10 Computer Applications

Updated 14 October 2026 · Fact-checked

Operators are symbols that act on operands. Java operators are unary, binary or ternary in form, and arithmetic, relational, logical, assignment, increment/decrement or shorthand in type. Expressions are evaluated by precedence and associativity, not BODMAS: postfix and prefix first, then * / %, then + −, relational, logical and assignment. Bitwise and shift operators are excluded.

What Operators in Java is about

Operator questions are the most reliable 2-mark items in Section A, and they also decide whether Section B programs give correct answers. The 2024 paper asked candidates to evaluate x += x++ * ++x % 2 for x = 4; the 2025 paper asked for 42 / 6 % 2. Examiners found candidates unclear on pre and post increment and on operator precedence, and advised evaluating by Java's operator hierarchy rather than BODMAS.

The syllabus asks for: forms of operators (unary, binary, ternary); types (arithmetic, relational, logical, assignment, increment, decrement, shorthand); counters and accumulators; hierarchy (precedence and associativity); prefix and postfix; the new operator for dynamic memory; the dot operator to reach class members; and System.out.print() and println(). Bitwise and shift operators are not included.

Weightage: CISCE publishes no chapter weightage. Section A (40 marks) is compulsory: 1-mark MCQs and 2-mark short answers including output and error questions; in Section B you answer any four of six 15-mark programming questions written in Java.Source: CISCE ICSE Computer Applications (661) specimen paper structure for 2027

Key concepts

Forms and types of operators

Forms (by number of operands):
Unary - one operand: ++a, --a, a++, a--, -a, !flag
Binary - two operands: a + b, a > b, a && b
Ternary - three operands: condition ? value1 : value2

Types:
Arithmetic: + - * / % (% gives the remainder: 17 % 5 = 2; with int operands / gives the quotient: 17 / 5 = 3)
Relational (result boolean): < > <= >= == !=
Logical (on boolean values): && (AND), || (OR), ! (NOT)
Assignment: =
Shorthand (compound assignment): += -= *= /= %= (a += 5 means a = a + 5)
Increment and decrement: ++ and --
Conditional (ternary): ?:

Note: = assigns; == compares.

Worked example

(2 marks) Classify as unary, binary or ternary: (a) !found (b) x % y (c) (a > b) ? a : b (d) count++

Try it first, then show the solutionSolution
  1. (a) unary; (b) binary - 1 mark.
  2. (c) ternary; (d) unary - 1 mark.

Answer: (a) unary (b) binary (c) ternary (d) unary

Prefix and postfix increment and decrement

Prefix (++a, --a): change then use: the variable is changed first and the new value is used in the expression.
Postfix (a++, a--): use then change: the old value is used in the expression and the variable is changed afterwards.

Example: int a = 5; int b = a++ + ++a;
a++ gives 5 (a becomes 6); ++a makes a 7 and gives 7; b = 5 + 7 = 12; finally a = 7.

Alone as a statement (a++; or ++a;) both simply add 1.

Worked example

(2 marks) int p = 3, q = 4; int r = p++ * q-- + --p; Find r, p and q.

Try it first, then show the solutionSolution
  1. p++ gives 3 (p = 4); q-- gives 4 (q = 3); 3 × 4 = 12 - 1 mark.
  2. --p makes p 3 and gives 3; r = 12 + 3 = 15 - 1 mark.

Answer: r = 15, p = 3, q = 3

Precedence and associativity

Precedence decides which operator is applied first; associativity decides the order among operators of equal precedence. From highest to lowest (syllabus operators):
1. Postfix: a++ a--
2. Unary: ++a --a, unary -, !
3. Multiplicative: * / % (left to right)
4. Additive: + - (left to right)
5. Relational: < > <= >=
6. Equality: == !=
7. Logical AND: &&
8. Logical OR: ||
9. Ternary: ?: (right to left)
10. Assignment: = += -= *= /= %= (right to left)

Because * / % share a level, they are done left to right: 42 / 6 % 2 = 7 % 2 = 1 (not 42 / 0). Brackets override precedence.

Compound assignment rule: in x += expr, Java takes the current value of x first, then evaluates expr, then stores x + expr. With x = 4: x += x++ * ++x % 2 → saved x = 4; x++ gives 4 (x = 5); ++x gives 6; 4 × 6 = 24; 24 % 2 = 0; x = 4 + 0 = 4.

Worked example

(1 mark) The output of 42 / 6 % 2 is:
(a) 1
(b) 10
(c) 2
(d) 0

Try it first, then show the solutionSolution
  1. / and % have equal precedence, so left to right: 42 / 6 = 7; 7 % 2 = 1.

Answer: (a) 1

Logical operators, ternary operator, counters and accumulators

Logical operators combine conditions: (a > b && a > c) is true only if both are true; (x < 0 || x > 100) is true if either is true; !(a == b) reverses the result. && and || are short-circuit: if the left side of && is false (or of || is true), the right side is not evaluated.

Ternary operator: variable = (condition) ? valueIfTrue : valueIfFalse;
Example: int max = (a > b) ? a : b;
Nested: int big = (a > b) ? ((a > c) ? a : c) : ((b > c) ? b : c);

Counter: a variable that counts how many times something happens, increased by 1: count++ (initialised to 0).
Accumulator: a variable that adds up (accumulates) values: sum += n (initialised to 0; a product accumulator starts at 1).

Worked example

(2 marks) Rewrite using the ternary operator:
if (marks >= 40)
result = "Pass";
else
result = "Fail";

Try it first, then show the solutionSolution
  1. Condition first, then ? true value : false value - 1 mark.
  2. result = (marks >= 40) ? "Pass" : "Fail"; - 1 mark.

Answer: result = (marks >= 40) ? "Pass" : "Fail";

new operator, dot operator and output statements

new operator: allocates memory dynamically (at run time) for an object or array and returns its reference: Student s = new Student(); int arr[] = new int[10];

Dot operator (.): accesses members of a class or object: s.display(); Math.sqrt(16); System.out.println(); obj.marks.

Output: System.out.print(x) prints x and stays on the same line; System.out.println(x) prints x and moves to the next line. + inside the brackets joins strings: System.out.println("Sum = " + (a + b)); The brackets around a + b make it add before joining; without them "Sum = " + a + b joins a and b as text.

Worked example

(2 marks) int a = 3, b = 4; give the output of:
System.out.println("Sum = " + a + b);
System.out.println("Sum = " + (a + b));

Try it first, then show the solutionSolution
  1. First line: "Sum = " + 3 gives "Sum = 3", then + 4 gives "Sum = 34" - 1 mark.
  2. Second line: brackets add first: 7 - 1 mark.

Answer: Sum = 34
Sum = 7

Writing Java expressions

To turn a formula into Java: put * for every multiplication (2ab → 2 * a * b), bracket numerators and denominators ((a + b) / (2 * a * b)), and use Math methods for powers and roots (Math.pow(x, 3), Math.sqrt(x)), and Math.abs for |x|.

Examples:
(a + b) / (2ab) → (a + b) / (2 * a * b)
ut + ½at² → u * t + 0.5 * a * t * t (or 1.0 / 2 * a * t * t; note 1 / 2 is 0 in integer division)
|a + b| / √(a² + b²) → Math.abs(a + b) / Math.sqrt(a * a + b * b)

Worked example

(2 marks) Write the Java expression for s = ut + ½at².

Try it first, then show the solutionSolution
  1. Every product needs *; t² as t * t - 1 mark.
  2. ½ must not be written 1 / 2 (that is 0): use 0.5 - 1 mark.

Answer: s = u * t + 0.5 * a * t * t;

Operators in Java in real life

Each concept, met in an everyday situation. Read the 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 ticket counter at a school fair records each ticket sold and the money collected through the day.

Which variable is a counter and which an accumulator? Write the statements for one sale of a ₹30 ticket.

Try it first, then show the solutionSolution
  1. Number of tickets goes up by one each sale: counter.
  2. Total money adds the price each sale: accumulator.
  3. tickets++; total += 30;

Answer: tickets is a counter (tickets++;) and total is an accumulator (total += 30;), both starting at 0.

Memory hook: Counters count by one; accumulators add amounts.

Prefix vs postfix

Imagine a queue token machine: on one desk the clerk calls out the current token and then advances the display; on another, he advances the display and then calls out the new token.

Which desk behaves like postfix and which like prefix?

Try it first, then show the solutionSolution
  1. Use the old value, then increase: postfix (token++).
  2. Increase first, then use the new value: prefix (++token).

Answer: The first desk is postfix (use then change); the second is prefix (change then use).

Memory hook: Postfix: use then change; prefix: change then use.

Logical operators

Suppose a cinema allows entry to a film only if a person is at least 13 years old AND has a ticket, and gives a discount if the person is a student OR a senior citizen.

Write the two conditions in Java.

Try it first, then show the solutionSolution
  1. Entry needs both: age >= 13 && hasTicket.
  2. Discount needs either: isStudent || age >= 60.

Answer: boolean entry = (age >= 13 && hasTicket); boolean discount = (isStudent || age >= 60);

Memory hook: AND needs all; OR needs any.

Topics in this chapter

Operators in Java: syntax and key facts

Precedence ladder
  1. 1.postfix
  2. 2.prefix/unary/!
  3. 3.* / %
  4. 4.+ −
  5. 5.< > <= >=
  6. 6.== !=
  7. 7.&&
  8. 8.||
  9. 9.?:
  10. 10.= += −= …
Equal levels: left to right (assignment and ternary: right to left).
Increment rules
a++ / a--: use then change; ++a / --a: change then use
In x += e, x's old value is saved first.
Ternary
var = (condition) ? valueIfTrue : valueIfFalse;
Integer arithmetic
17 / 5 = 3, 17 % 5 = 2; −17 % 5 = −2
Sign of % follows the left operand.

How the board asks Operators in Java

The question patterns to expect, and the method that works for each.

Question typeHow it is askedMethod
Evaluate expression (2 marks)x += x++ * ++x % 2 when x = 4 (2024); 42 / 6 % 2 (2025).Write the value of each operand under it, apply precedence, then left-to-right; remember the saved value in compound assignment.
Java expression (2 marks)Write a mathematical formula as a Java expression.Every product with *, brackets for numerators/denominators, Math methods for powers, roots and modulus.
Programs (15 marks)Counters, accumulators and ternary operators appear inside most Section B programs.Initialise counters and sums to 0 (products to 1) before loops.

Tricks to remember Operators in Java

Short memory aids. Say each one aloud once, then use it on a question the same day.

  • PUMA RELATES

    Postfix, Unary, Multiplicative, Additive, RELational, Equality, AND, OR (Ternary), Assignment last.

    Use it when: Precedence order.

  • Plus before = change first

    When ++ comes before the name, the change comes before the use.

    Use it when: Prefix vs postfix.

Operators in Java: board-level solved questions

Ordered from board level to HOTS. Cover the solution, write your own, then compare step by step.

Example 1: Equal precedence · 1 mark · MCQBoard level

What is the value of 20 % 6 * 3 / 2?
(a) 3
(b) 2
(c) 12
(d) 1

Try it first, then show the solutionSolution
  1. Left to right: 20 % 6 = 2; 2 * 3 = 6; 6 / 2 = 3.

Answer: (a) 3

Example 2: Short-circuit · 1 mark · MCQHOTS / competency

int i = 5; boolean t = (i > 10) && (++i > 5); What are t and i?
(a) true, 6
(b) false, 6
(c) false, 5
(d) true, 5

Try it first, then show the solutionSolution
  1. i > 10 is false, so && does not evaluate ++i; i stays 5.

Answer: (c) false, 5

Example 3: Compound assignment with increments · 2 marks · Very short answerHarder board level

Evaluate x += x++ * ++x % 2; when x = 4.

Try it first, then show the solutionSolution
  1. x += e means x = 4 + e (old x saved). x++ gives 4, x becomes 5; ++x gives 6.
  2. 4 * 6 = 24; 24 % 2 = 0; x = 4 + 0 = 4.

Answer: x = 4

Example 4: Decrement puzzle · 2 marks · Short answerHOTS / competency

int x = 10; x -= x-- - --x; Find x.

Try it first, then show the solutionSolution
  1. Saved x = 10. x-- gives 10 (x = 9); --x makes x 8 and gives 8.
  2. 10 − 8 = 2; x = 10 − 2 = 8.

Answer: x = 8

Example 5: Java expression · 2 marks · Very short answerBoard level

Write the Java expression for |a + b| / √(a² + b²).

Try it first, then show the solutionSolution
  1. |a + b| → Math.abs(a + b).
  2. √(a² + b²) → Math.sqrt(a * a + b * b) (or Math.pow).

Answer: Math.abs(a + b) / Math.sqrt(a * a + b * b)

Example 6: Ternary maximum of three · 2 marks · Short answerHarder board level

int a = 12, b = 25, c = 18; int big = (a > b) ? ((a > c) ? a : c) : ((b > c) ? b : c); What is big? Trace.

Try it first, then show the solutionSolution
  1. a > b is 12 > 25: false, so evaluate (b > c) ? b : c.
  2. 25 > 18 is true, so big = 25.

Answer: big = 25

Example 7: Profit or loss program · 15 marks · Long answerHarder board level

Write a program to accept the cost price and selling price of an article and print whether there is a profit or a loss, its amount and its percentage, using the ternary operator.

Try it first, then show the solutionSolution
  1. import java.util.Scanner;
    class ProfitLoss
    {
    public static void main(String args[])
    {
    Scanner sc = new Scanner(System.in);
    System.out.print("Cost price: ");
    double cp = sc.nextDouble();
    System.out.print("Selling price: ");
    double sp = sc.nextDouble();
  2. double diff = sp - cp;
    String result = (diff >= 0) ? "Profit" : "Loss";
    double amt = (diff >= 0) ? diff : -diff;
    double percent = amt * 100 / cp;
  3. System.out.println(result + " = " + amt);
    System.out.println(result + " % = " + percent);
    }
    }
  4. Trace 1: cp 800, sp 920: diff = 120.0, Profit, amt 120.0, percent = 12000.0 / 800 = 15.0.
  5. Trace 2: cp 500, sp 450: diff = −50.0, Loss, amt 50.0, percent = 5000.0 / 500 = 10.0.

Answer: Sample run:
Cost price: 800
Selling price: 920
Profit = 120.0
Profit % = 15.0

Case-study practice (Section B style)

Read the situation, then answer every part. In the board paper this is a 10-mark question split into 2 + 3 + 5 marks.

The canteen counter

Imagine a canteen program that adds the price of each item sold to a total and counts the items. At closing, it prints the total and the average price. A student wrote: int count; double total; ... total =+ price; count = count++;

  1. (i) · 2 marks

    Which variable is a counter and which an accumulator? What must they be initialised to?

    Answer

    Answer: count is a counter and total an accumulator; both must be initialised to 0 before use.

    1 mark each.

  2. (ii) · 3 marks

    Explain the bug in total =+ price; and correct it.

    Answer

    Answer: =+ is read as = +price, which assigns price to total instead of adding it. Correct: total += price; (or total = total + price;).

    Bug 2 marks; correction 1 mark.

  3. (iii) · 5 marks

    Explain why count = count++; never increases count, and give the correct statement and the average formula.

    Answer

    Answer: count++ gives the old value and then increments count, but the assignment then stores that old value back into count, so count stays the same. Correct: count++; Average: double avg = total / count; (count must be more than 0).

    Explanation 3 marks; correction 1 mark; average 1 mark.

Where the marks are

How a typical answer is split into step marks. Show every step: a right final answer alone rarely earns full marks.

Evaluate x += x++ * ++x % 2 when x = 4. (2 marks) (2 marks)

StepMarks
Correct operand values: 4 (saved), 4, 6.1
24 % 2 = 0; final x = 4.1

Program: profit or loss with ternary operator. (15 marks) (15 marks)

StepMarks
Class, main, Scanner and inputs.3
Difference computed.2
Ternary for Profit/Loss.3
Amount (positive) by ternary.2
Percentage on cost price.3
Output with labels.2

Where students lose marks in Operators in Java

The slips examiners see most often, and what to write instead.

  • Mistake: Evaluating by BODMAS

    The 2024 and 2025 examiners advised evaluating by Java's operator hierarchy, not BODMAS; in 2025 candidates who chose 0 for 42 / 6 % 2 had misapplied precedence.

    Do this: * / % are on one level and go left to right.

    Usually costs: 1 mark.

  • Mistake: Confusing prefix and postfix

    The 2024 examiners noted candidates were unclear on pre and post increment.

    Do this: Postfix: use then change; prefix: change then use. Write the value under each operand.

    Usually costs: 1 to 2 marks.

  • Mistake: Not handling shorthand assignment

    In 2024 candidates were unclear on shorthand operators in x += ....

    Do this: Expand to x = x + (...), using x's value before the right side changes it.

    Usually costs: 1 mark.

  • Mistake: Missing * or Math methods in expressions

    In 2024 candidates missed Math.abs for |a + b|; in 2025 they missed * between terms.

    Do this: Translate every symbol: product = *, |x| = Math.abs, √ = Math.sqrt.

    Usually costs: 1 mark.

Practice questions on Operators in Java

Write each answer on paper first. Open the hint only if you are stuck, and the answer only when you have finished.

  1. Q1 · 1 mark · MCQBoard level

    Which is a ternary operator?
    (a) ++
    (b) &&
    (c) ?:
    (d) %

    Hint

    Three operands.

    Answer

    (c) ?:

  2. Q2 · 1 mark · MCQHarder board level

    int a = 7; System.out.println(a++ + a);
    (a) 14
    (b) 15
    (c) 16
    (d) 13

    Hint

    Use then change.

    Answer

    (b) 15 (7 + 8)

  3. Q3 · 1 mark · MCQBoard level

    Which operator creates memory for an object at run time?
    (a) dot
    (b) new
    (c) =
    (d) ==

    Hint

    Dynamic memory.

    Answer

    (b) new

  4. Q4 · 2 marks · Very short answerBoard level

    Distinguish between = and == with an example.

    Hint

    Assign vs compare.

    Answer

    = is the assignment operator that stores a value (a = 5;). == is a relational operator that compares two values and gives true or false (a == 5).

  5. Q5 · 2 marks · Short answerHOTS / competency

    int m = 6, n = 9; m *= n % 4 + m--; Find m.

    Hint

    Old m saved.

    Answer

    Saved m = 6. n % 4 = 1; m-- gives 6 (m becomes 5); 1 + 6 = 7; m = 6 × 7 = 42.

  6. Q6 · 2 marks · Very short answerHarder board level

    Write the Java expression for (x³ + y³) / (x − y)².

    Hint

    Math.pow.

    Answer

    (Math.pow(x, 3) + Math.pow(y, 3)) / Math.pow(x - y, 2)

  7. Q7 · 2 marks · Very short answerHarder board level

    Give the output: int a = 10, b = 3; System.out.println(a / b + " " + a % b + " " + (a > b && b > 5));

    Hint

    Three parts.

    Answer

    3 1 false

  8. Q8 · 15 marks · Long answerHarder board level

    Write a program to accept the temperature in Celsius and print it in Fahrenheit (F = 9/5 × C + 32), and print 'Hot' if F is above 100 and 'Not hot' otherwise, using the ternary operator.

    Hint

    Avoid 9/5 integer division.

    Answer

    import java.util.Scanner;
    class Temperature
    {
    public static void main(String args[])
    {
    Scanner sc = new Scanner(System.in);
    System.out.print("Celsius: ");
    double c = sc.nextDouble();
    double f = 9.0 / 5 * c + 32;
    String msg = (f > 100) ? "Hot" : "Not hot";
    System.out.println("Fahrenheit = " + f);
    System.out.println(msg);
    }
    }
    Trace with 40: 9.0 / 5 = 1.8; 1.8 × 40 = 72.0; + 32 = 104.0; output: Fahrenheit = 104.0 / Hot. (Writing 9 / 5 would give 1 and a wrong answer.)

  9. Q9 · 2 marks · Short answerHOTS / competency

    Why is 1 / 2 * a * t * t wrong for ½at² in Java?

    Hint

    Integer division.

    Answer

    1 / 2 is integer division giving 0, so the whole product becomes 0. Use 0.5 * a * t * t or 1.0 / 2 * a * t * t.

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. 1.17 % 5 = ?Show answer

    2

  2. 2.Which goes first, * or +?Show answer

    *

  3. 3.Associativity of assignment?Show answer

    Right to left.

  4. 4.What does the dot operator do?Show answer

    Accesses members of a class or object.

  5. 5.Initial value of a product accumulator?Show answer

    1

Best order to study it

  1. Forms and types of operators.
  2. Prefix and postfix with traces.
  3. Precedence and associativity; compound assignment rule.
  4. Logical and ternary operators; counters and accumulators.
  5. new, dot, print and println.
  6. Writing Java expressions.

Quick revision checklist

The night before the exam: can you do each of these without looking?

  • Unary, binary, ternary.
  • Arithmetic, relational, logical, assignment, shorthand, ++/--, ?:.
  • Postfix: use then change; prefix: change then use.
  • * / % left to right before + −.
  • Counter: count++; accumulator: sum += x.
  • new allocates memory; dot reaches members.

Operators in Java: frequently asked questions

Are bitwise operators like & and | in the syllabus?

No. Bitwise and shift operators are excluded; learn the logical operators && and ||.

Why does x = x++; leave x unchanged?

x++ gives the old value and then increments x, but the assignment stores the old value back, undoing the increment.

Is % allowed with double values?

Yes, Java allows it (7.5 % 2 = 1.5), but ICSE questions usually use it with integers.

Based on: CISCE ICSE 2027 Computer Applications syllabus; CISCE Analysis of Pupil Performance ICSE 2025: Computer Applications (with the 2025 board paper)