ICSE Class 10 · Computer Applications (Java) · Output questions 2027

ICSE Computer Applications output questions, sorted by the trap each one sets.

ICSE Computer Applications output questions look small: four lines of Java and the question "what does this print?". They are built on a short list of traps, and a student who knows the list stops guessing. This page groups 44 original snippets by trap, gives the exact output of each (every one was compiled and run in Java 21), and traces the hardest step by step. In our live mini batch the same traps are drilled against a timer and checked in BlueJ while the class watches.

Live online · 44 traced snippets · eleven trap families · every answer run in BlueJ · Section A drilled weekly · first class free

Start here

Courses that train output tracing

The ICSE Java course where the mini batch drills these traps, the Class 11 and 12 Computer Science course where the same tracing habit carries straight into ISC, and the data structures course for the student who wants to see how tracing becomes algorithm analysis.

Ans. The short version

ICSE Computer Applications output questions give a short Java fragment and ask exactly what it prints. They sit in Section A, the 40 compulsory marks, as one-mark MCQs and two-mark answers. Almost all of them test the same traps: integer division and type promotion, pre and post increment, char arithmetic, String methods and immutability, Math return types, loop counts, switch fall-through, the ternary operator, short-circuit && and ||, array default values and wrapper methods. The reliable method is a written trace table, never a guess. Modern Age Coders drills these live in a Tuesday and Wednesday mini batch in India, or personalised one to one.

Q1. Where do the arithmetic traps hide?

Predict the output Java ICSE: division, increments and char arithmetic

Cover the Output column, write your answer, then check. Each row names the rule, so a wrong answer tells you exactly what to revise.

Trap 1: integer division and type promotion

#CodeOutputThe trap
1int a = 17, b = 5;
double d = a / b;
System.out.println(d);
3.017 / 5 is worked out as int first (3); only then is it widened to 3.0
2System.out.println(1 + 2 + "3" + 4 + 5);3345Left to right: 1 + 2 is 3, then the String takes over and every later + joins
3System.out.println((double) (9 / 4) + " " + (double) 9 / 4);2.0 2.25Cast after the division keeps the lost fraction lost; cast before saves it
4System.out.println(-7 / 2 + " " + -7 % 2);-3 -1Integer division cuts towards zero; the remainder takes the sign of the left operand

Trap 2: pre and post increment, and compound assignment

#CodeOutputThe trap
5int a = 5;
int b = a++ + ++a;
System.out.println(a + " " + b);
7 12a++ gives 5 then a is 6; ++a makes a 7 and gives 7; b is 5 + 7
6int k = 3;
k = k++;
System.out.println(k);
3The old value 3 is saved, k becomes 4, then the assignment writes 3 back
7int m = 10, n = 3;
m -= n-- - --n;
System.out.println(m + " " + n);
8 1n-- gives 3 (n is 2), --n gives 1; m is 10 - (3 - 1)
8int y = 7;
y /= 2.0;
System.out.println(y);
3A compound operator casts back to int silently: (int) 3.5 is 3

Trap 3: char arithmetic and casting

#CodeOutputThe trap
9char ch = 'a';
ch++;
System.out.println(ch + 1);
99ch++ keeps the char type ('b'), but ch + 1 is int arithmetic: 98 + 1
10char c = '7';
int n = c - '0';
System.out.println(n * 2 + " " + c * 2);
14 110c - '0' turns a digit character into its value; c * 2 doubles the code 55
11char p = 'P';
System.out.println(p + 2 + "" + (char) (p + 2));
82R80 + 2 is added before the empty String arrives; the cast turns 82 back into R
Trace it: snippet 12compound plus increments
int x = 4;
x += x++ * --x;
System.out.println(x);

// Output: 20

x += e means x = x + (e). Java saves the left x (4) before it evaluates e, so the later changes to x do not touch that saved 4.

StepValue usedx after
Save left x44
x++45
--x44
4 * 4164
4 + 16 assigned2020

Precedence and the rest of this family are on operators in Java for ICSE Class 10.

Q2. Which library method answers catch students out?

ICSE Java output questions with answers: Strings, Math and wrapper classes

Two facts settle most of these. A String never changes after it is made, so a method returns a new String that must be stored. And every Math method has a fixed return type, so the number of decimal places in the answer is part of the answer.

Trap 4: String methods and String immutability

#CodeOutputThe trap
13String s = "board";
s.toUpperCase();
s.concat("exam");
System.out.println(s);
boardBoth results were thrown away; s still points to "board"
14String t = "MISSISSIPPI";
System.out.println(t.indexOf("SS", 3) + " " + t.lastIndexOf('I', 7));
5 7The search starts at index 3, so the SS at 2 is skipped; lastIndexOf searches backwards from 7
15String w = " Java Exam ";
System.out.println(w.trim().length() + w.length());
229 + 13: two ints are added. trim removes only the outer spaces
16String a = "ICSE", b = "icse";
System.out.println(a.equals(b) + " " + a.equalsIgnoreCase(b) + " " + a.compareToIgnoreCase(b));
false true 0Case matters to equals only; 0 means equal when case is ignored
17String s = "CAT";
System.out.println(s.compareTo("CATALOG"));
-4No character differs, so compareTo returns the difference in lengths: 3 - 7
18static void change(String s) {
  s = s + "!";
  System.out.print(s + " ");
}
// in main:
String s = "Hi";
change(s);
System.out.println(s);
Hi! HiThe method builds a new String in its own copy of s; the caller's s is untouched

Trap 5: Math method return types

#CodeOutputThe trap
19System.out.println(Math.sqrt(16) + Math.cbrt(27));7.0sqrt and cbrt always return double, even for perfect squares and cubes
20System.out.println(Math.pow(2, 3) + " " + (int) Math.pow(2, 3));8.0 8pow returns double; only the cast removes the .0
21System.out.println(Math.max(3, 7.5) + " " + Math.min(-2, -2.0));7.5 -2.0Mix an int with a double and the int is promoted, so the result is double
22System.out.println(Math.floor(-3.5) + " " + Math.round(3.49) + " " + Math.round(-3.51));-4.0 3 -4floor goes down and returns double; round of a double returns a long, so no .0

Trap 6: wrapper classes and Character methods

#CodeOutputThe trap
23System.out.println(Character.isLetterOrDigit('_') + " " + Character.isWhitespace('\t'));false trueThe underscore is neither a letter nor a digit; a tab counts as whitespace
24char c = Character.toUpperCase('5');
System.out.println(c + 1);
54toUpperCase leaves a digit alone; '5' is code 53, plus 1
25String n = "25";
System.out.println(n + 5 + " " + (Integer.parseInt(n) + 5) + " " + Integer.valueOf(n) / 2);
255 30 12Joined, then added, then unboxed and divided as int
26System.out.println(Double.parseDouble("3") / 2 + Integer.toString(70).length());3.51.5 plus the length of "70", which is 2

The full list of Math methods in the syllabus, with return types, is on Math library methods for ICSE Class 10, and autoboxing, parse methods and the Character tests are on wrapper and library classes.

Q3. How do you count what a loop prints?

Loop output questions ICSE: iteration counts and nested loops

Loop questions ask for the output, the number of passes, or both. Never count in your head. Write one row per pass with every variable that changes.

Trap 7: how many times does it run?

#CodeOutputThe trap
27int c = 0;
for (int i = 10; i > 0; i -= 3) c++;
System.out.println(c);
4i takes 10, 7, 4 and 1; at -2 the test fails
28int n = 50;
do { n += 5; } while (n < 10);
System.out.println(n);
55A do-while body always runs once before the condition is checked
29int t = 0;
for (int i = 0; i < 5; i++);
{ t++; }
System.out.println(t);
1The semicolon is the whole loop body; the block after it runs once
30for (int i = 1; i <= 3; i++) {
  for (int j = i; j <= 3; j++)
    System.out.print(j);
  System.out.println();
}
123
23
3
The inner loop starts at i, so each line is one shorter and starts one higher
Trace it: snippet 31digits in a while loop
int n = 3047, r = 0;
while (n > 0) {
    r = r * 10 + n % 10;
    n /= 10;
}
System.out.println(r);

// Output: 7403

Four passes, one per digit. The middle zero survives because 740 is a real step.

Passn % 10rn after
177304
247430
307403
4374030, loop ends
Trace it: snippet 32break inside nested loops
int count = 0;
for (int i = 1; i <= 4; i++)
    for (int j = 1; j <= 4; j++) {
        if (j > i) break;
        count++;
    }
System.out.println(count);

// Output: 10

break leaves only the inner loop; the outer loop carries on, so the count grows 1 + 2 + 3 + 4.

ij values countedInner loop stopscount
11break at j = 21
21, 2break at j = 33
31, 2, 3break at j = 46
41, 2, 3, 4test fails at j = 510

Loops that build whole programs, such as digit sums, factor counts and series, are worked through on loop programs in Java for ICSE Class 10.

Q4. What about switch, the ternary operator, && and arrays?

Dry run questions ICSE Class 10: switch, ternary, short-circuit and arrays

These four traps share one idea: some visible code never runs, or runs more than you expect. Mark which lines execute before writing any output.

#CodeOutputThe trap
Trap 8: switch fall-through
33int d = 2;
switch (d) {
  case 1: System.out.print("A");
  case 2: System.out.print("B");
  case 3: System.out.print("C"); break;
  default: System.out.print("D");
}
BCExecution enters at case 2 and falls into case 3 until the break
34char g = 'x';
switch (g) {
  case 'a': System.out.print(1);
  default: System.out.print(0);
  case 'b': System.out.print(2); break;
  case 'c': System.out.print(3);
}
02default need not be last; with no break it falls into case 'b'
35for (int i = 1; i <= 3; i++) {
  switch (i) {
    case 1: System.out.print("x"); break;
    case 2: System.out.print("y");
    default: System.out.print("z");
  }
}
xyzzi = 2 prints y and falls into z; i = 3 goes straight to default
Trap 9: the ternary operator
36int p = 5;
int q = p++ > 5 ? p : p * 10;
System.out.println(p + " " + q);
6 605 > 5 is false, but p has already become 6 before the false branch runs
37System.out.println(true ? 1 : 2.0);1.0The two branches are promoted to one type, double, even though 1 is chosen
Trap 10: short-circuit && and ||
38int x = 5, y = 10;
boolean r = (x > 6) && (++y > 10);
System.out.println(r + " " + y);
false 10The left side is false, so ++y is never evaluated
39int i = 0;
boolean f = (i++ == 0) && (i++ == 1) || (i++ == 5);
System.out.println(f + " " + i);
true 2&& binds first and is true, so the third i++ is skipped
Trap 11: arrays and default values
40int[] a = new int[4];
a[1] = 5;
System.out.println(a[0] + a[1] + a.length);
9Unset int elements are 0; length is a field, no brackets: 0 + 5 + 4
41double[] d = new double[2];
boolean[] f = new boolean[2];
String[] s = new String[2];
char[] c = new char[2];
System.out.println(d[0] + " " + f[1] + " " + s[0] + " " + (int) c[0]);
0.0 false null 0Each type has its own default: 0.0, false, null and the character with code 0
42int[] p = {1, 2, 3};
int[] q = p;
q[0] = 9;
System.out.println(p[0] + p.length);
12q is a second name for the same array, so p[0] is now 9; 9 + 3
43int[][] m = {{1, 2, 3}, {4, 5, 6}};
System.out.println(m.length + " " + m[1].length + " " + m[1][2] * m[0][1]);
2 3 12m.length counts rows, m[1].length counts columns; 6 * 2
Trace it: snippet 44an array that feeds itself
int[] x = {3, 6, 9, 12};
for (int i = 1; i < x.length; i++)
    x[i] = x[i] + x[i - 1];
System.out.println(x[3]);

// Output: 30

Each pass uses the value the previous pass just changed. Adding the original values gives 21 and loses the mark.

iSum workedArray after the pass
startnone{3, 6, 9, 12}
16 + 3{3, 9, 9, 12}
29 + 9{3, 9, 18, 12}
312 + 18{3, 9, 18, 30}

Q5. How should an output answer be written in the exam?

Exam technique: writing the trace and showing working in Section A

Section A is 40 compulsory marks: Question 1 is twenty one-mark MCQs and Question 2 is ten parts of two marks each. Output questions appear in both, and each shape needs a slightly different habit.

In an MCQ, trace before you read the options

The wrong options are usually the answers a trap produces. For snippet 9 the choices might be b, c, 98 and 99. A student who skims the options first is drawn to b. Work the answer on the margin, then find it in the list.

In a two-mark part, show a compact trace

Write a small table of the variables that change, then the output on its own line. The output itself must be right; the trace is how you get it right and check it in seconds.

Copy the layout, not just the values

print and println decide where lines break, and a missing space between two printed numbers changes the answer. Write each println as a new line and show spaces where the code prints " ".

Mark the type of every number

Before writing a number, ask: is this int, long or double? That one question catches 3.0 against 3, 8.0 against 8 and 1.0 against 1, which are the commonest slips on this page.

Tick each line as it runs

For switch, short-circuit and ternary questions, put a small tick beside every statement that executes. Lines without a tick produce nothing, however close to the answer they sit.

Budget the time

The paper is two hours for 100 marks, so Section A deserves roughly a minute per mark. A loop of more than five passes earns its trace table; a one-line String call does not.

When a fragment would not compile at all, the question is about error finding rather than output, and that shape has its own page: ICSE Class 10 Java error finding questions. One-mark questions of every other kind are on ICSE Computer Applications MCQ questions.

Q6. How does the mini batch drill output questions?

From paper trace to BlueJ run, every week

The skill comes from committing to an answer under time pressure, being wrong, and finding the exact step where the trace went off course.

  1. A timed set on Tuesday

    At the 5:30 PM IST class, students get a fresh set of fragments from two or three trap families and write their outputs on paper against the clock. Nobody sees the answers until everyone has committed.

  2. Run in BlueJ on a shared screen

    The teacher pastes each fragment into BlueJ and runs it while the group watches. The real output appears beside each student's guess, so there is no arguing about who was right.

  3. Wrong outputs traced again, aloud

    A student with a wrong answer re-traces it in front of the group, one variable at a time, until the step that broke is found. Usually it is one of the eleven traps above, and that trap goes on the student's own list.

  4. Traces inside Wednesday's program

    At the 8:00 PM IST class, the program of the week is dry run before it is executed, so tracing becomes a way to check one's own Section B code as well.

  5. Full mock tests from December

    Output questions then appear inside complete two-hour papers, marked like the board, so the habit holds when the paper is long and the clock is running.

With at most six students in the batch, every wrong output in every set gets looked at. The full mock ladder is described on the ICSE specimen paper and mock tests page.

Batch or personalised: you choose

Drill output questions in the mini batch, or trace one to one

The snippets, the trace tables and the BlueJ checks are the same in both formats. In India, families pick the fixed evening mini batch or a private slot; ICSE students abroad learn one to one. Billing is monthly, with no admission fee.

Option 1 · Fixed batch timings

Mini batch, Tuesday 5:30 PM and Wednesday 8 PM

₹2,999

per month, two live classes a week

  • Tuesday 5:30 PM and Wednesday 8:00 PM IST, live
  • Up to six ICSE Class 10 students per batch
  • A timed output set every Tuesday
  • Each answer run in BlueJ while the group watches
  • Wrong outputs re-traced aloud, never skipped
Book a free demo in this batch

Option 2 · Choose your own timing

Personalised one to one

₹4,999

per month, one private class a week, at a time set with you

  • Slot chosen by the family, in India or abroad
  • Time spent only on the traps your child keeps falling into
  • Trace tables built together until they become a habit
  • Harder snippets added as accuracy improves
  • Same teachers, same 2027 syllabus, same BlueJ checks
Ask for a personalised plan

A student who already writes good programs but drops easy Section A marks to increments, char arithmetic or Math return types often needs only a few one to one sessions on those traps. A student who wants steady practice across all of Section A and Section B is better served by two batch classes a week. Fees are shown in your own currency.

Studying outside India?

Output tracing practice for ICSE students outside India

ICSE schools abroad sit the same Computer Applications paper, so the same eleven traps decide the same Section A marks. Outside India the drills run one to one, in an early evening slot in the student's own time zone.

Where you liveTime differenceUsual class window, local timeFormat
India (IST)
every Indian city
ISTTue 5:30 PM, Wed 8:00 PMMini batch or 1-on-1
United Arab Emirates
Dubai, Sharjah
1 h 30 min behind India3:00 PM to 9:00 PMPersonalised 1-on-1
Indonesia and Thailand
West Java, Bangkok area
1 h 30 min ahead of India3:30 PM to 9:00 PMPersonalised 1-on-1
Singapore
Singapore
2 h 30 min ahead of India3:30 PM to 9:00 PMPersonalised 1-on-1

The slot is agreed after the free demo and moved around school tests when needed. More on how this works for families overseas is on ICSE Computer Applications classes in the Gulf and abroad.

What families say

Rated 4.9 across 547 Google reviews

Real reviews from real families. We neither write nor commission them.

★★★★★

"The one step solution for my son. Modern Age Coders make learning coding so simple that kids love it. The teachers explain complex concepts clearly with practical exercises and interactive content."

Ria Mukherjee

Parent

★★★★★

"Modern Age Coders has been a game-changer for me. I struggled to grasp IT concepts and coding before joining, but their classes transformed everything. I can now confidently write complex programs with ease."

Samriddha Mondal

Student

★★★★★

"One of the most wonderful education centres out there. Education is not limited to school syllabus but focuses on skill development."

Vansh Agarwal

Student

★★★★★

"My child Dhairya is really enjoying the Modern Age Coders classes. This is his first online class and he eagerly looks forward to it. I can already see his improvement, and the teachers are very cooperative."

Sonam Oswal

Parent of Dhairya

★★★★★

"Modern Age Coders have wonderful teachers who teach in a clear, easy and practical way. The teacher boosts students' confidence and inspires them to learn without hesitation."

Sonu Goyal

Parent

★★★★★

"I highly recommend this computer coding class! The teachers are incredibly knowledgeable and passionate about coding."

Ritu Kedia

Parent

The rest of the Class 10 series

More pages for Class 10 board students

Every page in the ICSE Class 10 Computer Applications series, grouped by what you need: classes, each chapter, Section B programs, question practice, notes and revision, and the exam itself.

CBSE Class 10 AI (417): The Mon and Wed 9 PM AI batch CBSE AI 417 syllabus explained CBSE AI important questions Sample paper and mock tests

Questions about output questions

What students ask about ICSE Java output questions

How do you solve predict the output questions in Java for ICSE?

Trace, do not guess. Write the variables across the top of a small table, add one row each time a statement changes a value, and only then write the output. Before writing any number, decide whether it is an int or a double, and before writing any line, check whether the code used print or println.

Where do output questions come in the ICSE Computer Applications paper?

In Section A, the 40 compulsory marks. Question 1 has twenty one-mark MCQs, some showing a fragment with four possible outputs. Question 2 has ten two-mark parts, several of which typically ask for an output or a loop count.

What are the most common traps in ICSE Java output questions?

Integer division, increments, char arithmetic, unstored String results, Math return types, loop counts, switch fall-through, ternary promotion, short-circuit && and ||, array defaults and wrapper methods. Each has original snippets on this page.

Why does 5 / 2 give 2 in Java and not 2.5?

When both operands are int, Java does integer division and drops the fraction. Make one operand a double, as in 5.0 / 2 or (double) 5 / 2, to get 2.5. Casting after the division, as in (double) (5 / 2), is too late and gives 2.0.

What is the difference between x++ and ++x in an output question?

Both add 1 to x. x++ gives the old value to the expression and then increases x; ++x increases x first and gives the new value. In a line such as b = a++ + ++a, trace each term separately, left to right, writing down x after every step.

Why does Math.sqrt(16) print 4.0 and not 4?

Because sqrt, cbrt, pow, ceil and floor all return double, so Java prints a decimal point even when the value is whole. Math.round of a double returns a long, so it prints without .0. Writing 4 instead of 4.0 is marked wrong.

How do I count how many times a loop runs?

List every value the control variable takes, including the one that makes the test fail, then count the values that passed. For i starting at 10, falling by 3 while it stays above 0, the values are 10, 7, 4 and 1, so the loop runs four times. A do-while loop always runs at least once.

What is a dry run in ICSE Class 10?

A dry run means executing a program by hand, line by line, while keeping a table of each variable's value. It is how output questions are solved, and the fastest way to find a logic error in your own Section B program.

Is recursion asked in ICSE 2027 output questions?

No. Recursion is not in the ICSE Computer Applications syllabus for 2027, so no output question should need it. Concentrate on operators, loops, nested loops, Strings, Math, wrapper classes and single and double dimensional arrays.

Do you teach output questions in live classes?

Yes. In the mini batch every Tuesday there is a timed set of output questions, each answer is then run in BlueJ on a shared screen, and every wrong answer is traced again aloud. Students who need more focus can take personalised one to one classes at a time the family chooses.

Are these output questions copied from past ICSE papers?

No. Every snippet on this page is original, written to test one trap at a time, and every output was checked by compiling and running the code in Java. Past papers use the same kinds of trap, so practising these prepares a student for the real ones.

Start

Try a free live output-tracing class

In the free demo your child predicts the output of a short set of Java fragments against the clock, then watches each one run in BlueJ and re-traces any that went wrong with the mentor. Afterwards you hear plainly which traps cost your child marks, and whether the mini batch or one to one suits them better.

Want the wider picture first? See ICSE Computer Applications important questions or the ICSE Class 10 Java classes.

WhatsApp us · +91 91233 66161 · connect@modernagecoders.com

Every class is live video. The form requests a callback and reserves nothing.

We call within a few hours. No card, no enrolment fee.

Want it sooner? Book a priority demo

A full live class of about 45 to 60 minutes at a slot you pick, with a written skill report and learning roadmap on WhatsApp afterwards. The fee is adjusted against your first month if you enrol.

Book a priority demo

Keep exploring Modern Age Coders

By class and age

Learn more

Free resources

From the blog

Start here