★★★★★
"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
ICSE Class 10 · Computer Applications (Java) · Output questions 2027
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
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.

The batch / ICSE CA
Class 9 and 10 Computer Applications in a mini batch, with a timed set of output questions every Tuesday and each answer run in BlueJ.
Open the course →
Next step / ISC
For students moving on to ISC Computer Science, where output tracing returns with longer programs and harder loops.
Open the course →
Beyond the syllabus / DSA
For the student who enjoys dry runs and wants to count steps the way programmers analyse algorithms.
Open the course →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?
Cover the Output column, write your answer, then check. Each row names the rule, so a wrong answer tells you exactly what to revise.
| # | Code | Output | The trap |
|---|---|---|---|
| 1 | int a = 17, b = 5;double d = a / b;System.out.println(d); | 3.0 | 17 / 5 is worked out as int first (3); only then is it widened to 3.0 |
| 2 | System.out.println(1 + 2 + "3" + 4 + 5); | 3345 | Left to right: 1 + 2 is 3, then the String takes over and every later + joins |
| 3 | System.out.println((double) (9 / 4) + " " + (double) 9 / 4); | 2.0 2.25 | Cast after the division keeps the lost fraction lost; cast before saves it |
| 4 | System.out.println(-7 / 2 + " " + -7 % 2); | -3 -1 | Integer division cuts towards zero; the remainder takes the sign of the left operand |
| # | Code | Output | The trap |
|---|---|---|---|
| 5 | int a = 5;int b = a++ + ++a;System.out.println(a + " " + b); | 7 12 | a++ gives 5 then a is 6; ++a makes a 7 and gives 7; b is 5 + 7 |
| 6 | int k = 3;k = k++;System.out.println(k); | 3 | The old value 3 is saved, k becomes 4, then the assignment writes 3 back |
| 7 | int m = 10, n = 3;m -= n-- - --n;System.out.println(m + " " + n); | 8 1 | n-- gives 3 (n is 2), --n gives 1; m is 10 - (3 - 1) |
| 8 | int y = 7;y /= 2.0;System.out.println(y); | 3 | A compound operator casts back to int silently: (int) 3.5 is 3 |
| # | Code | Output | The trap |
|---|---|---|---|
| 9 | char ch = 'a';ch++;System.out.println(ch + 1); | 99 | ch++ keeps the char type ('b'), but ch + 1 is int arithmetic: 98 + 1 |
| 10 | char c = '7';int n = c - '0';System.out.println(n * 2 + " " + c * 2); | 14 110 | c - '0' turns a digit character into its value; c * 2 doubles the code 55 |
| 11 | char p = 'P';System.out.println(p + 2 + "" + (char) (p + 2)); | 82R | 80 + 2 is added before the empty String arrives; the cast turns 82 back into R |
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.
| Step | Value used | x after |
|---|---|---|
| Save left x | 4 | 4 |
| x++ | 4 | 5 |
| --x | 4 | 4 |
| 4 * 4 | 16 | 4 |
| 4 + 16 assigned | 20 | 20 |
Precedence and the rest of this family are on operators in Java for ICSE Class 10.
Q2. Which library method answers catch students out?
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.
| # | Code | Output | The trap |
|---|---|---|---|
| 13 | String s = "board";s.toUpperCase();s.concat("exam");System.out.println(s); | board | Both results were thrown away; s still points to "board" |
| 14 | String t = "MISSISSIPPI";System.out.println(t.indexOf("SS", 3) + " " + t.lastIndexOf('I', 7)); | 5 7 | The search starts at index 3, so the SS at 2 is skipped; lastIndexOf searches backwards from 7 |
| 15 | String w = " Java Exam ";System.out.println(w.trim().length() + w.length()); | 22 | 9 + 13: two ints are added. trim removes only the outer spaces |
| 16 | String a = "ICSE", b = "icse";System.out.println(a.equals(b) + " " + a.equalsIgnoreCase(b) + " " + a.compareToIgnoreCase(b)); | false true 0 | Case matters to equals only; 0 means equal when case is ignored |
| 17 | String s = "CAT";System.out.println(s.compareTo("CATALOG")); | -4 | No character differs, so compareTo returns the difference in lengths: 3 - 7 |
| 18 | static void change(String s) { s = s + "!"; System.out.print(s + " ");}// in main:String s = "Hi";change(s);System.out.println(s); | Hi! Hi | The method builds a new String in its own copy of s; the caller's s is untouched |
| # | Code | Output | The trap |
|---|---|---|---|
| 19 | System.out.println(Math.sqrt(16) + Math.cbrt(27)); | 7.0 | sqrt and cbrt always return double, even for perfect squares and cubes |
| 20 | System.out.println(Math.pow(2, 3) + " " + (int) Math.pow(2, 3)); | 8.0 8 | pow returns double; only the cast removes the .0 |
| 21 | System.out.println(Math.max(3, 7.5) + " " + Math.min(-2, -2.0)); | 7.5 -2.0 | Mix an int with a double and the int is promoted, so the result is double |
| 22 | System.out.println(Math.floor(-3.5) + " " + Math.round(3.49) + " " + Math.round(-3.51)); | -4.0 3 -4 | floor goes down and returns double; round of a double returns a long, so no .0 |
| # | Code | Output | The trap |
|---|---|---|---|
| 23 | System.out.println(Character.isLetterOrDigit('_') + " " + Character.isWhitespace('\t')); | false true | The underscore is neither a letter nor a digit; a tab counts as whitespace |
| 24 | char c = Character.toUpperCase('5');System.out.println(c + 1); | 54 | toUpperCase leaves a digit alone; '5' is code 53, plus 1 |
| 25 | String n = "25";System.out.println(n + 5 + " " + (Integer.parseInt(n) + 5) + " " + Integer.valueOf(n) / 2); | 255 30 12 | Joined, then added, then unboxed and divided as int |
| 26 | System.out.println(Double.parseDouble("3") / 2 + Integer.toString(70).length()); | 3.5 | 1.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 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.
| # | Code | Output | The trap |
|---|---|---|---|
| 27 | int c = 0;for (int i = 10; i > 0; i -= 3) c++;System.out.println(c); | 4 | i takes 10, 7, 4 and 1; at -2 the test fails |
| 28 | int n = 50;do { n += 5; } while (n < 10);System.out.println(n); | 55 | A do-while body always runs once before the condition is checked |
| 29 | int t = 0;for (int i = 0; i < 5; i++);{ t++; }System.out.println(t); | 1 | The semicolon is the whole loop body; the block after it runs once |
| 30 | for (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 |
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.
| Pass | n % 10 | r | n after |
|---|---|---|---|
| 1 | 7 | 7 | 304 |
| 2 | 4 | 74 | 30 |
| 3 | 0 | 740 | 3 |
| 4 | 3 | 7403 | 0, loop ends |
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.
| i | j values counted | Inner loop stops | count |
|---|---|---|---|
| 1 | 1 | break at j = 2 | 1 |
| 2 | 1, 2 | break at j = 3 | 3 |
| 3 | 1, 2, 3 | break at j = 4 | 6 |
| 4 | 1, 2, 3, 4 | test fails at j = 5 | 10 |
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?
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.
| # | Code | Output | The trap |
|---|---|---|---|
| Trap 8: switch fall-through | |||
| 33 | int 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");} | BC | Execution enters at case 2 and falls into case 3 until the break |
| 34 | char 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);} | 02 | default need not be last; with no break it falls into case 'b' |
| 35 | for (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"); }} | xyzz | i = 2 prints y and falls into z; i = 3 goes straight to default |
| Trap 9: the ternary operator | |||
| 36 | int p = 5;int q = p++ > 5 ? p : p * 10;System.out.println(p + " " + q); | 6 60 | 5 > 5 is false, but p has already become 6 before the false branch runs |
| 37 | System.out.println(true ? 1 : 2.0); | 1.0 | The two branches are promoted to one type, double, even though 1 is chosen |
| Trap 10: short-circuit && and || | |||
| 38 | int x = 5, y = 10;boolean r = (x > 6) && (++y > 10);System.out.println(r + " " + y); | false 10 | The left side is false, so ++y is never evaluated |
| 39 | int 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 | |||
| 40 | int[] a = new int[4];a[1] = 5;System.out.println(a[0] + a[1] + a.length); | 9 | Unset int elements are 0; length is a field, no brackets: 0 + 5 + 4 |
| 41 | double[] 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 0 | Each type has its own default: 0.0, false, null and the character with code 0 |
| 42 | int[] p = {1, 2, 3};int[] q = p;q[0] = 9;System.out.println(p[0] + p.length); | 12 | q is a second name for the same array, so p[0] is now 9; 9 + 3 |
| 43 | int[][] m = {{1, 2, 3}, {4, 5, 6}};System.out.println(m.length + " " + m[1].length + " " + m[1][2] * m[0][1]); | 2 3 12 | m.length counts rows, m[1].length counts columns; 6 * 2 |
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.
| i | Sum worked | Array after the pass |
|---|---|---|
| start | none | {3, 6, 9, 12} |
| 1 | 6 + 3 | {3, 9, 9, 12} |
| 2 | 9 + 9 | {3, 9, 18, 12} |
| 3 | 12 + 18 | {3, 9, 18, 30} |
Q5. How should an output answer be written in the exam?
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.
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.
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.
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 " ".
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.
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.
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?
The skill comes from committing to an answer under time pressure, being wrong, and finding the exact step where the trace went off course.
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.
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.
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.
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.
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
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
₹2,999
per month, two live classes a week
Option 2 · Choose your own timing
₹4,999
per month, one private class a weektwo private classes a week, at a time set with you
Outside India: the ICSE Computer Applications course runs as personalised one to one, two private classes a week at a time set in your own time zone. The mini batch is taught for families in India.
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?
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 live | Time difference | Usual class window, local time | Format |
|---|---|---|---|
| India (IST) every Indian city | IST | Tue 5:30 PM, Wed 8:00 PM | Mini batch or 1-on-1 |
| United Arab Emirates Dubai, Sharjah | 1 h 30 min behind India | 3:00 PM to 9:00 PM | Personalised 1-on-1 |
| Indonesia and Thailand West Java, Bangkok area | 1 h 30 min ahead of India | 3:30 PM to 9:00 PM | Personalised 1-on-1 |
| Singapore Singapore | 2 h 30 min ahead of India | 3:30 PM to 9:00 PM | Personalised 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
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
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
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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
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.
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