ICSE Class 10 · Computer Applications (Java) · Find the error 2027

Find the error in Java, ICSE Class 10: one bug per snippet, named and fixed.

Find the error Java questions in ICSE Class 10 show a few lines of code with one thing wrong and ask you to name the error, say what kind it is, and write the line correctly. This page gives 40 original snippets, each with exactly one bug, sorted into syntax, runtime and logical errors. Next to each one is what javac or Java actually reported when we ran it, and the fix. In our live mini batch students hunt these bugs against a timer and then watch BlueJ prove them right or wrong.

Live online · 40 one-bug snippets · real compiler messages · syntax, runtime, logical · first class free

Start here

Courses where debugging is practised

The ICSE Java course in which the mini batch runs these bug hunts, the Class 11 and 12 Computer Science course where longer programs make debugging a daily skill, and the data structures course for students who like finding the one line that breaks everything.

Ans. The short version

Find the error questions in ICSE Class 10 Computer Applications give a short Java fragment with one mistake and ask you to identify it, classify it and correct it. There are three kinds. A syntax error breaks the rules of Java, so the compiler refuses the program. A runtime error compiles but stops the program while it runs, such as division by zero or an index out of bounds. A logical error compiles and runs but gives the wrong answer. Modern Age Coders drills all three live in a Tuesday and Wednesday mini batch in India, or personalised one to one.

Q1. What are syntax, logical and runtime errors in Java?

Syntax, logical and runtime errors in ICSE Java, side by side

A syntax error is caught by the compiler, a runtime error is caught by Java while the program runs, and a logical error is caught by nobody except the person who checks the answer. That one sentence classifies every snippet on this page.

QuestionSyntax errorRuntime errorLogical error
Does it compile?NoYesYes
Does it run to the end?It never startsNo, it stops at the bad lineYes
Who reports it?The compiler (javac, or BlueJ's Compile button)The Java runtime, as an exceptionNobody; the output is simply wrong
Typical causeMissing semicolon, wrong type, undeclared variable, misspelt keywordDivision of an int by zero, bad array or String index, text that is not a numberWrong formula, wrong condition, loop one pass short, wrong starting value
How you find itRead the message and the line numberRead the exception name and the line in the stack traceDry run with known input and compare with the expected answer
Also calledCompile-time errorExceptionSemantic or logic error

How to classify an error in three questions

  1. Would javac accept every line?

    Check semicolons, brackets, the types on both sides of each =, the spelling and case of names, and that every variable is declared and set before use. If a line fails, it is a syntax error.

  2. Could any line crash with legal code?

    Look for an int divided by something that can be 0, an index that can reach the length, a parse method or nextInt fed text, or a null String. If so, it is a runtime error.

  3. Does it give the answer the question wanted?

    Dry run it with small input whose answer you know. If the output differs, it is a logical error; name the line and the wrong idea.

A fragment that compiles and runs correctly belongs to a different question shape, tracing, covered on ICSE Java output questions.

Q2. Which syntax errors do ICSE questions use?

Syntax error questions ICSE: the code, what javac says, the fix

Cover the last two columns, find the bug, then check. The middle column is the first line javac 21 printed for that fragment; BlueJ shows the same text under the editor.

#Code with one errorjavac saysCorrect it
1int total = 0
total = total + 45;
';' expectedint total = 0; Every statement ends with a semicolon
2int runs = 64;
system.out.println(runs);
package system does not existSystem.out.println(runs); Java is case sensitive; System is a class with a capital S
3String city = 'Pune';unclosed character literalString city = "Pune"; Single quotes hold exactly one char; Strings need double quotes
4int weight = 52.5;incompatible types: possible lossy conversion from double to intdouble weight = 52.5; A decimal literal is a double and cannot be squeezed into an int without a cast
5int points;
points = points + 10;
variable points might not have been initializedint points = 0; Local variables get no default value
6int age = 15;
if (age = 15)
  System.out.println("Class 10");
incompatible types: int cannot be converted to booleanif (age == 15) One = assigns; == compares
7static int cube(int n) {
  int c = n * n * n;
}
missing return statementAdd return c; before the closing brace; a method declared int must return an int
8char grade = "A";incompatible types: String cannot be converted to charchar grade = 'A'; Double quotes make a String even for one letter
9void greet() { ... }
// inside static main:
greet();
non-static method greet() cannot be referenced from a static contextDeclare it static void greet(), or call it through an object of the class
10for (int k = 1; k <= 5; k++) {
  System.out.print(k);
}
System.out.println(k);
cannot find symbol (symbol: variable k)Declare int k; before the loop and write for (k = 1; k <= 5; k++). A variable declared in the for header dies when the loop ends
11int score = 70;
int score = 85;
variable score is already defined in method main(String[])score = 85; Declare once, assign as often as you like
12if (x > 5)
  System.out.println("big");
  System.out.println("checked");
else
  System.out.println("small");
'else' without 'if'Put the two println lines inside { }. Without braces the if owns only one statement
13String word = "BlueJ";
System.out.println(word.length);
cannot find symbol (symbol: variable length)word.length() For a String, length is a method
14int[] marks = {80, 75, 91};
System.out.println(marks.length());
cannot find symbol (symbol: method length())marks.length For an array, length is a field, no brackets
15int r = Math.round(4.6);incompatible types: possible lossy conversion from long to intlong r = Math.round(4.6); or int r = (int) Math.round(4.6); round of a double returns long
16switch (day) {
  case 1: ... break;
  case 2: ... break;
  case 2: ... break;
}
duplicate case labelChange the third label to case 3: Each case value may appear once
17static void area(int s) {
  return s * s;
}
incompatible types: unexpected return valuestatic int area(int s) A void method cannot hand back a value
18while (n > 0) {
  n--;
  break;
  System.out.println(n);
}
unreachable statementMove the println above the break, or delete it. Java refuses code that can never run
19boolean pass = 1;incompatible types: int cannot be converted to booleanboolean pass = true; Java booleans are only true and false, never 0 or 1
20float rate = 7.5;incompatible types: possible lossy conversion from double to floatfloat rate = 7.5f; A literal with a decimal point is double unless it carries f

Snippet 3 is a useful warning: javac reported three errors for that single line, because one bad quote confuses everything after it. Always fix the first message first and compile again. Snippets 4, 15, 19 and 20 are all about types, which have their own page: data types, input and type casting in Java for ICSE Class 10.

Q3. What is a runtime error in Java, with an example?

Runtime error questions: the exception Java throws and why

A runtime error is code that compiles but stops while it runs, because a value at that moment makes the operation impossible. Java names the problem in an exception. Each message below is copied from a java 21 run of the snippet.

#Code with one errorJava stops withCorrect it
21int boxes = 48, children = 0;
System.out.println(boxes / children);
ArithmeticException: / by zeroTest first: if (children != 0) before dividing
22int n = 17;
System.out.println(n % 0);
ArithmeticException: / by zeroThe remainder operator divides too, so a zero divisor crashes it in the same way
23int[] runs = {12, 40, 7, 33, 9};
for (int i = 0; i <= runs.length; i++)
  sum += runs[i];
ArrayIndexOutOfBoundsException: Index 5 out of bounds for length 5i < runs.length The last index is length minus 1
24String code = "ICSE";
System.out.println(code.charAt(code.length()));
StringIndexOutOfBoundsException: Index 4 out of bounds for length 4code.charAt(code.length() - 1) prints E
25String s = "Kolkata";
System.out.println(s.substring(3, 9));
StringIndexOutOfBoundsException: Range [3, 9) out of bounds for length 7s.substring(3) prints kata. The end index may be at most the length
26int fee = Integer.parseInt("12.5");NumberFormatException: For input string: "12.5"double fee = Double.parseDouble("12.5"); parseInt accepts whole numbers only
27Scanner sc = new Scanner(System.in);
int qty = sc.nextInt();
// the user types: ten
java.util.InputMismatchExceptionThe code is legal; the input is not. Tell the user to enter digits, or read with next() and check before converting
28String pet = null;
System.out.println(pet.length());
NullPointerException: Cannot invoke "String.length()" because "pet" is nullGive the String a value first, for example String pet = "cat";
29int size = -3;
int[] list = new int[size];
NegativeArraySizeException: -3Check that the size read from the user is positive before creating the array
Not an error: snippet 30the same division with double
double boxes = 48, children = 0;
System.out.println(boxes / children);
System.out.println(0.0 / 0);

// Output:
// Infinity
// NaN

Division by zero crashes only integer arithmetic. With a double on either side Java prints Infinity or NaN and carries on, which makes this a logical error if the program was supposed to refuse.

ExpressionResultError type
48 / 0 (int)ArithmeticExceptionRuntime
48 % 0 (int)ArithmeticExceptionRuntime
48.0 / 0InfinityNone, or logical
0.0 / 0NaN, not a numberNone, or logical

Index errors are the commonest runtime bug inside Section B answers. Programs that walk through Strings and arrays safely are worked through on ICSE Class 10 String programs and 2D array programs.

Q4. How do you find a logical error when nothing complains?

Logical error examples in Java: compiles, runs, prints the wrong answer

A logical error shows up only when the output is compared with the expected answer. "Printed" is what the faulty code gave when run; the last column is what the fix gave.

#Code with one errorPrintedCorrect itNow prints
31int a = 7, b = 8, c = 8;
double avg = (a + b + c) / 3;
7.0(a + b + c) / 3.0 so the division is done in double7.666666666666667
32int f = 0;
for (int i = 1; i <= 5; i++) f *= i;
0int f = 1; A product must start at 1120
33int s = 0;
for (int i = 1; i < 10; i++) s += i;
// meant: sum of 1 to 10
45i <= 10 The loop stopped one pass short55
34int marks = 25;
if (marks >= 40);
  System.out.println("Pass");
PassDelete the semicolon after the condition; it is an empty statement that the if controls(nothing)
35String ans = "YES".toLowerCase();
System.out.println(ans == "yes");
falseans.equals("yes") == compares references, not the characterstrue
36int p = 3, q = 9;
p = q;
q = p;
System.out.println(p + " " + q);
9 9Use a third variable: int t = p; p = q; q = t;9 3
37int got = 430;
double pct = got / 500 * 100;
0.0got * 100.0 / 500 430 / 500 is 0 in int arithmetic86.0
38int[] temps = {-4, -9, -2, -7};
int max = 0;
for (int v : temps) if (v > max) max = v;
0int max = temps[0]; Start from a real element, not from 0-2
39int n = -7;
String t = n % 2 == 1 ? "odd" : "even";
evenn % 2 != 0 -7 % 2 is -1, not 1odd
40int sc = 92;
if (sc >= 60) gr = "C";
else if (sc >= 75) gr = "B";
else if (sc >= 90) gr = "A";
CTest the highest band first: 90, then 75, then 60A
A logical error that never endsthe infinite loop
int i = 1;
while (i <= 10) {
    System.out.println(i);
    i--;
}

// Fix: i++ instead of i--

This compiles and never crashes, so it is not a syntax or runtime error. It is a logical error: the update moves i away from the exit. In our test, a counter added to the loop showed i at -999999 after a million passes, still running.

Passi printedi after i--i <= 10?
110true
20-1true
3-1-2true
and so onfalls forevernever above 10always true

Loops that stop a pass early or never stop are drilled with iteration counts on loop programs for ICSE Class 10, and integer division, the cause of snippets 31 and 37, is traced step by step on operators in Java for ICSE Class 10.

Q5. How do you answer "correct the code" in the exam?

Correct the code ICSE Java: rewriting a program that has one bug

Write the corrected line in full, name the error type in one word, and give a one-line reason. Rewriting the whole program wastes time unless the question asks for it. Here are two Section B style methods, each with one bug, the way they come up in class.

Faultysum of the even digits
static int evenDigitSum(int n) {
    int sum = 0;
    while (n > 0) {
        int d = n % 10;
        if (d % 2 == 0)
            sum = d;
        n /= 10;
    }
    return sum;
}
// evenDigitSum(58246) returns 8

Logical error. The line sum = d replaces the total instead of adding to it, so only the last even digit reached (8, the leftmost) survives.

Correctedone line changed
static int evenDigitSum(int n) {
    int sum = 0;
    while (n > 0) {
        int d = n % 10;
        if (d % 2 == 0)
            sum += d;
        n /= 10;
    }
    return sum;
}
// evenDigitSum(58246) returns 20

6 + 4 + 2 + 8 is 20. The answer in the exam: "sum = d; should be sum += d; logical error, the total is overwritten."

Faultycount the capital letters
static int capitals(String s) {
    int c = 0;
    for (int i = 1; i < s.length(); i++)
        if (Character.isUpperCase(s.charAt(i)))
            c++;
    return c;
}
// capitals("Delhi Public School") returns 2

Logical error. The loop starts at index 1, so the D at index 0 is never checked.

Correctedstart at index 0
static int capitals(String s) {
    int c = 0;
    for (int i = 0; i < s.length(); i++)
        if (Character.isUpperCase(s.charAt(i)))
            c++;
    return c;
}
// capitals("Delhi Public School") returns 3

Test with a word whose first letter matters. A test string such as "india Gate" would have hidden this bug completely.

Quote the line, then rewrite it

Copy the faulty line exactly, write "should be", then the corrected line. The examiner sees at once that you found the right line and fixed it the right way.

Name the type in one word

Syntax, runtime or logical. If the question asks which type, a correct fix with no label can still lose the mark.

Fix the cause, not the symptom

For snippet 23 the cause is the <= in the loop test. Wrapping the addition in a check on i hides the crash but leaves the wrong loop in place.

Test with input that can expose the bug

Try zero, a negative number, the first and last positions, and an input whose answer you know. Bugs live at the edges.

Errors also appear as one-mark items in Question 1; see ICSE Computer Applications MCQ questions, and for a full spread of Section A shapes, ICSE Computer Applications important questions.

Q6. How are error finding questions taught live?

Error finding questions ICSE computer: how the mini batch hunts bugs

Debugging improves when a student commits to an answer, sees the real compiler message, and explains the gap aloud. That is the loop each class repeats.

  1. Tuesday: a timed set of planted bugs

    At the 5:30 PM IST class each student gets eight to ten fragments, each hiding one error. They write the faulty line, the type and the fix on paper before anything is compiled.

  2. BlueJ decides, on a shared screen

    The teacher compiles or runs each fragment while the group watches. The real message or exception appears, so a guess of "runtime" for a missing semicolon is corrected on the spot.

  3. The student who got it wrong explains why

    Saying "I thought the if owned both lines" fixes the idea behind the bug, and the whole batch hears it.

  4. Wednesday: bugs inside whole programs

    At the 8:00 PM IST class a complete Section B program arrives with one fault planted in it. Students find it by testing with chosen inputs, the habit that catches their own mistakes in the board paper.

  5. Mock tests and an error log

    From December, full two-hour papers are marked the way the board marks them, and every lost mark goes into the student's error log with its type, so revision targets real weak spots.

With at most six students, every wrong answer is discussed. The weekly program list that these bugs are planted in is on ICSE Class 10 Java programs for practice, and the mock paper ladder is on the ICSE specimen paper and mock tests page.

Batch or personalised: you choose

Hunt bugs in the mini batch, or debug one to one

Both formats use the same one-bug fragments, the same BlueJ checks and the same error log. Families in India choose the evening mini batch or a private slot; ICSE students abroad learn one to one. Billing is monthly, and there is 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 set of planted bugs every Tuesday
  • Every guess checked by compiling in BlueJ
  • Wrong answers explained aloud and logged
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

  • A slot the family picks, in India or abroad
  • Your child's own Section B code debugged line by line
  • Extra time on the error type they miss most
  • Testing with edge-case inputs built into every program
  • Same teachers, same 2027 syllabus, same compiler checks
Ask for a personalised plan

A student whose programs often fail to compile, or who freezes at a screen of red messages, gains a lot from a few one to one sessions spent reading errors together. A student who wants weekly practice across both sections of the paper usually does better in the batch. Fees appear in your own currency.

Studying outside India?

Debugging practice for ICSE students outside India

ICSE schools abroad sit the same Computer Applications paper, and javac prints the same messages in every country. Outside India the bug hunts run one to one, at an after-school hour 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 fixed after the free demo and can shift around school tests. How classes work for overseas families is explained 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 error finding

What students ask about find the error questions in ICSE Java

What are the three types of errors in Java for ICSE Class 10?

Syntax errors, runtime errors and logical errors. A syntax error breaks the grammar of Java, so the program does not compile. A runtime error compiles but stops the program while it runs, for example dividing an int by zero. A logical error compiles and runs to the end but produces a wrong result because the idea in the code is wrong.

What is the difference between a syntax error and a logical error?

A syntax error is found by the compiler before the program runs, and it comes with a message and a line number. A logical error is invisible to the compiler and to Java: the program runs normally and prints an answer, just the wrong one. You find a logical error only by checking the output against an answer you already know.

Is division by zero a syntax, runtime or logical error?

For int values it is a runtime error. The code compiles, then Java stops with ArithmeticException: / by zero when the line runs. The same happens with the % operator. With double values there is no crash: Java prints Infinity or NaN, so if the program should have refused that input, the mistake is logical.

Is a missing semicolon a syntax error?

Yes. javac reports "';' expected" and points to the end of the line where the semicolon belongs. The program cannot run until it is fixed. Note the opposite case too: an extra semicolon straight after if (...) or for (...) compiles happily and becomes a logical error.

Is an infinite loop a runtime error or a logical error?

An infinite loop is a logical error. The code is legal and Java does not throw any exception; the loop simply never reaches its exit because the update moves the variable the wrong way or never changes it. You notice it only because the program never finishes, so you trace the loop variable to find the fault.

Is ArrayIndexOutOfBoundsException a runtime error?

Yes. Using an index below 0 or equal to or above the array length compiles without complaint, but Java throws ArrayIndexOutOfBoundsException when that line runs, with a message such as "Index 5 out of bounds for length 5". The usual cause is a loop test that says "less than or equal to length" where it should say "less than length".

How do I write the answer to a correct the code question in ICSE?

Quote the faulty line, write the corrected line next to it, and name the error type if asked. Add one short reason, such as "a char literal needs single quotes". Rewrite the full program only when the question says so. Make one change per error, since examiners look for the specific line that was wrong.

Is using == to compare Strings an error in Java?

It compiles and runs, so it is not a syntax or runtime error, but it usually gives the wrong answer, which makes it a logical error. == checks whether two variables point to the same String object, not whether they hold the same characters. Use equals, or equalsIgnoreCase when case should not matter.

Are find the error questions asked in the ICSE Computer Applications paper?

Questions asking students to name the type of an error, or to correct a faulty statement, have appeared in Section A of past ICSE Computer Applications papers, as one-mark or two-mark parts. Section B rewards the same skill indirectly, because a program with a bug in it loses marks for the wrong output.

Do you teach error finding in live classes?

Yes. The ICSE mini batch runs a timed set of planted bugs every Tuesday at 5:30 PM IST, checks every answer by compiling in BlueJ on a shared screen, and plants a bug inside Wednesday's full program. Students who need closer help take personalised one to one classes at a time the family chooses.

Start

Book a free live debugging class

In the free demo your child gets a short set of Java fragments, each hiding one bug, names the line and the error type, then watches BlueJ compile and run them with the mentor. Afterwards you hear plainly which kinds of error your child misses and whether the mini batch or one to one is the better fit.

Prefer to look around first? See ICSE Java output 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