---
title: "Top 20 Java Programs for ICSE Class 10 (With Code)"
description: "The top 20 Java programs for ICSE Class 10, each with the exam-style question and tested BlueJ code: special numbers, strings, arrays, patterns and more."
slug: top-20-java-programs-for-icse-class-10
canonical: https://learn.modernagecoders.com/blog/top-20-java-programs-for-icse-class-10/
date: 2026-07-02
dateModified: 2026-07-02
category: "Java"
tags: ["Java", "ICSE", "Computer Applications", "BlueJ", "Exam Preparation"]
keywords: ["java programs for icse class 10", "icse class 10 java programs", "important java programs icse", "icse computer applications programs", "special number programs java", "icse class 10 computer applications", "bluej programs icse", "icse board java programs"]
readTime: "16 min read"
author: "Modern Age Coders"
---
# Top 20 Java Programs for ICSE Class 10 (With Code)

> The programs that keep coming back in the ICSE Computer Applications paper, each with its exam-style question and tested BlueJ code.

![Top 20 Java programs for ICSE Class 10 with code, exam preparation](/images/blog/top-20-java-programs-for-icse-class-10/00-hero.png)

*By Modern Age Coders · 2026-07-02 · 16 min read*

If you are preparing for the ICSE Class X Computer Applications exam, one thing becomes clear fast: the same kinds of Java programs come back year after year. Special numbers, string handling, arrays, patterns, and a menu-driven program or two. Once you can write these confidently, most of the program-writing paper stops being a surprise.

This guide collects the top 20 Java programs that matter most for ICSE Class 10. For each one you get the exam-style question and a clean, working program written the way you would in BlueJ. Every program here was actually compiled and run, so the code you copy is the code that works.

Do not just read them. Type each program into BlueJ, run it, change the input, and watch what happens. That is how the logic sticks, and it is exactly how we work in our [Java classes for ICSE students](/java-programming-for-icse-students): write, run, break it, and fix it.

## How the ICSE Computer Applications Exam Works

ICSE Class X Computer Applications is taught and examined in Java, usually written in the BlueJ environment. The written paper runs for two hours and carries 100 marks. It has two parts: Section A is worth 40 marks and is compulsory, covering the whole syllabus with short questions. Section B is worth 60 marks and is where the full program-writing questions sit, and you get a choice of which ones to attempt. Alongside the paper, there is 100 marks of Internal Assessment based on lab work.

![ICSE Class X Computer Applications exam blueprint: 2 hours, 100 marks, Section A 40 and Section B 60, plus Internal Assessment](/images/blog/top-20-java-programs-for-icse-class-10/05-blueprint.png)

*The 20 programs below are aimed squarely at Section B, where you write full programs.*

The program questions are built from the same syllabus units: taking input with Scanner, using Math library methods, conditions with if-else and switch, loops and nested loops, user-defined methods, and single and double dimensional arrays with string handling. The 20 programs below cover all of that ground.

> **How to use this list**

> Work through one family at a time. Learn the pattern for one program in a group, and the rest in that group start to feel familiar. Aim to write each from memory, not just recognise it.

## The 20 Programs at a Glance

Here are the 20 programs grouped into six families. If a group feels weak, that is exactly where to spend your next practice session.

![Map of 20 ICSE Class 10 Java programs grouped into six families: special numbers, number checks, series and maths, loops and menu, strings, arrays](/images/blog/top-20-java-programs-for-icse-class-10/01-category-map.png)

*Six families cover the whole program-writing paper.*

## Number and Special-Number Programs

This is the biggest and most-tested group. Special numbers look tricky at first, but they all follow one idea: pull out the digits, do something with them, and compare the result to the original number.

![Worked examples of four ICSE special numbers: Automorphic 25, Neon 9, Spy 1124, Disarium 135](/images/blog/top-20-java-programs-for-icse-class-10/02-special-numbers.png)

*Four ICSE favourites, with the actual working behind each.*

### 1. Prime Number

**Question:** Write a program to input a number and check whether it is a Prime number. A prime number has exactly two factors, 1 and the number itself.

```java
import java.util.*;
public class Prime {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.print("Enter a number: ");
        int n = sc.nextInt();
        int count = 0;
        for (int i = 1; i <= n; i++) {
            if (n % i == 0)
                count++;
        }
        if (count == 2)
            System.out.println(n + " is a Prime number.");
        else
            System.out.println(n + " is not a Prime number.");
    }
}
```

**Sample:** input 13 prints "13 is a Prime number."

### 2. Palindrome Number

**Question:** Write a program to check whether a number is a Palindrome. A palindrome reads the same forwards and backwards, like 121. Reverse the number and compare it with the original.

```java
import java.util.*;
public class PalindromeNumber {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.print("Enter a number: ");
        int n = sc.nextInt();
        int rev = 0, temp = n;
        while (temp != 0) {
            int d = temp % 10;
            rev = rev * 10 + d;
            temp = temp / 10;
        }
        if (rev == n)
            System.out.println(n + " is a Palindrome.");
        else
            System.out.println(n + " is not a Palindrome.");
    }
}
```

The reverse-and-compare idea shows up again and again. Here is the same logic drawn as a flowchart, which is worth knowing because ICSE sometimes asks for the algorithm too.

![Flowchart for checking a palindrome number: read n, reverse the digits in a loop, compare the reverse with the original](/images/blog/top-20-java-programs-for-icse-class-10/04-flowchart.png)

*The palindrome-number logic as a flowchart.*

### 3. Armstrong Number

**Question:** Write a program to check whether a 3-digit number is an Armstrong number. A number is Armstrong when the sum of the cubes of its digits equals the number, like 153 = 1 cube + 5 cube + 3 cube.

```java
import java.util.*;
public class Armstrong {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.print("Enter a 3-digit number: ");
        int n = sc.nextInt();
        int temp = n, sum = 0;
        while (temp != 0) {
            int d = temp % 10;
            sum = sum + d * d * d;
            temp = temp / 10;
        }
        if (sum == n)
            System.out.println(n + " is an Armstrong number.");
        else
            System.out.println(n + " is not an Armstrong number.");
    }
}
```

**Sample:** input 153 prints "153 is an Armstrong number."

### 4. Perfect Number

**Question:** Write a program to check whether a number is a Perfect number. A perfect number equals the sum of its factors excluding itself, like 28 = 1 + 2 + 4 + 7 + 14.

```java
import java.util.*;
public class Perfect {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.print("Enter a number: ");
        int n = sc.nextInt();
        int sum = 0;
        for (int i = 1; i < n; i++) {
            if (n % i == 0)
                sum = sum + i;
        }
        if (sum == n)
            System.out.println(n + " is a Perfect number.");
        else
            System.out.println(n + " is not a Perfect number.");
    }
}
```

### 5. Automorphic Number

**Question:** Write a program to check whether a number is Automorphic. A number is automorphic when its square ends with the number itself, like 25 whose square is 625.

```java
import java.util.*;
public class Automorphic {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.print("Enter a number: ");
        int n = sc.nextInt();
        int sq = n * n;
        String s1 = String.valueOf(n);
        String s2 = String.valueOf(sq);
        if (s2.endsWith(s1))
            System.out.println(n + " is an Automorphic number.");
        else
            System.out.println(n + " is not an Automorphic number.");
    }
}
```

### 6. Neon Number

**Question:** Write a program to check whether a number is a Neon number. In a neon number, the digits of its square add up to the number itself, like 9 whose square is 81 and 8 + 1 = 9.

```java
import java.util.*;
public class Neon {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.print("Enter a number: ");
        int n = sc.nextInt();
        int sq = n * n, sum = 0;
        while (sq != 0) {
            sum = sum + sq % 10;
            sq = sq / 10;
        }
        if (sum == n)
            System.out.println(n + " is a Neon number.");
        else
            System.out.println(n + " is not a Neon number.");
    }
}
```

### 7. Spy Number

**Question:** Write a program to check whether a number is a Spy number. In a spy number the sum of the digits equals the product of the digits, like 1124 where 1 + 1 + 2 + 4 = 8 and 1 x 1 x 2 x 4 = 8.

```java
import java.util.*;
public class Spy {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.print("Enter a number: ");
        int n = sc.nextInt();
        int temp = n, sum = 0, prod = 1;
        while (temp != 0) {
            int d = temp % 10;
            sum = sum + d;
            prod = prod * d;
            temp = temp / 10;
        }
        if (sum == prod)
            System.out.println(n + " is a Spy number.");
        else
            System.out.println(n + " is not a Spy number.");
    }
}
```

### 8. Disarium Number

**Question:** Write a program to check whether a number is a Disarium number. Here each digit is raised to the power of its position from the left, and the results are added to give the number, like 135 = 1 to the power 1 + 3 to the power 2 + 5 to the power 3.

```java
import java.util.*;
public class Disarium {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.print("Enter a number: ");
        int n = sc.nextInt();
        int len = String.valueOf(n).length();
        int temp = n, sum = 0;
        while (temp != 0) {
            int d = temp % 10;
            sum = sum + (int) Math.pow(d, len);
            len--;
            temp = temp / 10;
        }
        if (sum == n)
            System.out.println(n + " is a Disarium number.");
        else
            System.out.println(n + " is not a Disarium number.");
    }
}
```

> **One pattern, many special numbers**

> Notice how Automorphic, Neon, Spy, and Disarium all start by breaking a number into digits and end by comparing a result to the original. Master that shape once and you can write any special-number program the examiner invents.

## Series and Maths Programs

### 9. Fibonacci Series

**Question:** Write a program to print the Fibonacci series up to n terms. Each term is the sum of the two before it, starting from 0 and 1.

```java
import java.util.*;
public class Fibonacci {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.print("How many terms? ");
        int n = sc.nextInt();
        int a = 0, b = 1;
        System.out.print("Fibonacci series: ");
        for (int i = 1; i <= n; i++) {
            System.out.print(a + " ");
            int c = a + b;
            a = b;
            b = c;
        }
        System.out.println();
    }
}
```

**Sample:** 10 terms print 0 1 1 2 3 5 8 13 21 34.

### 10. Factorial of a Number

**Question:** Write a program to find the factorial of a number. The factorial of n is the product of all whole numbers from 1 to n.

```java
import java.util.*;
public class Factorial {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.print("Enter a number: ");
        int n = sc.nextInt();
        long fact = 1;
        for (int i = 1; i <= n; i++)
            fact = fact * i;
        System.out.println("Factorial of " + n + " = " + fact);
    }
}
```

The factorial grows fast, so the answer is stored in a long instead of an int.

### 11. Sum of Digits

**Question:** Write a program to find the sum of the digits of a number, like 1234 giving 10.

```java
import java.util.*;
public class SumOfDigits {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.print("Enter a number: ");
        int n = sc.nextInt();
        int temp = n, sum = 0;
        while (temp != 0) {
            sum = sum + temp % 10;
            temp = temp / 10;
        }
        System.out.println("Sum of digits = " + sum);
    }
}
```

### 12. HCF and LCM of Two Numbers

**Question:** Write a program to find the HCF and LCM of two numbers. The HCF is the largest number that divides both, and the LCM is the smallest number both divide into. Once you have the HCF, the LCM is just the two numbers multiplied and divided by the HCF.

```java
import java.util.*;
public class HcfLcm {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.print("Enter two numbers: ");
        int a = sc.nextInt();
        int b = sc.nextInt();
        int x = a, y = b;
        while (y != 0) {
            int r = x % y;
            x = y;
            y = r;
        }
        int hcf = x;
        int lcm = (a * b) / hcf;
        System.out.println("HCF = " + hcf);
        System.out.println("LCM = " + lcm);
    }
}
```

This uses the Euclidean method to find the HCF quickly. If you want the same idea explained step by step in another language, read our guide on [how to find the HCF and LCM in Python](/blog/how-to-find-hcf-and-lcm-in-python).

## Loops, Patterns and a Menu Program

### 13. Number Pattern (Floyd's Triangle)

**Question:** Write a program using nested loops to print Floyd's triangle for n rows, where the numbers run continuously across the rows.

```java
import java.util.*;
public class NumberPattern {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.print("Enter number of rows: ");
        int n = sc.nextInt();
        int num = 1;
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= i; j++) {
                System.out.print(num + " ");
                num++;
            }
            System.out.println();
        }
    }
}
```

Patterns are all about nested loops: the outer loop controls the rows, the inner loop controls what prints on each row. Change the inner loop and you get a completely different shape.

![Three ICSE pattern outputs from nested loops: Floyd's triangle, a number pyramid, and a star pattern](/images/blog/top-20-java-programs-for-icse-class-10/03-pattern-gallery.png)

*The same two-loop idea produces all three of these classic outputs.*

### 14. Menu-Driven Program (switch-case)

**Question:** Write a menu-driven program using switch-case to find the area of a circle, a square, or a rectangle based on the user's choice.

```java
import java.util.*;
public class MenuDriven {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("1. Area of Circle");
        System.out.println("2. Area of Square");
        System.out.println("3. Area of Rectangle");
        System.out.print("Enter your choice: ");
        int choice = sc.nextInt();
        switch (choice) {
            case 1:
                System.out.print("Enter radius: ");
                double r = sc.nextDouble();
                System.out.println("Area = " + (3.14 * r * r));
                break;
            case 2:
                System.out.print("Enter side: ");
                double s = sc.nextDouble();
                System.out.println("Area = " + (s * s));
                break;
            case 3:
                System.out.print("Enter length and breadth: ");
                double l = sc.nextDouble();
                double b = sc.nextDouble();
                System.out.println("Area = " + (l * b));
                break;
            default:
                System.out.println("Invalid choice.");
        }
    }
}
```

Examiners love switch-case because it tests whether you remember the break statement and the default case. Leave out break and every case below the match will run too.

## String Programs

String questions appear almost every year, often two of them. The key tools are length, charAt, and the character checks from the Character class.

The whole method toolkit behind these, charAt, substring, equals against ==, and the traps that cost marks, lives in our [string handling in Java guide](/blog/string-handling-in-java), worth a read before drilling this family.

### 15. Palindrome String

**Question:** Write a program to check whether a word is a Palindrome, like 'madam', ignoring the difference between uppercase and lowercase.

```java
import java.util.*;
public class PalindromeString {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.print("Enter a word: ");
        String s = sc.nextLine();
        String rev = "";
        for (int i = s.length() - 1; i >= 0; i--)
            rev = rev + s.charAt(i);
        if (s.equalsIgnoreCase(rev))
            System.out.println(s + " is a Palindrome.");
        else
            System.out.println(s + " is not a Palindrome.");
    }
}
```

### 16. Count Vowels and Consonants

**Question:** Write a program to count the number of vowels and consonants in a string.

```java
import java.util.*;
public class VowelsConsonants {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.print("Enter a string: ");
        String s = sc.nextLine().toLowerCase();
        int v = 0, c = 0;
        for (int i = 0; i < s.length(); i++) {
            char ch = s.charAt(i);
            if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u')
                v++;
            else if (ch >= 'a' && ch <= 'z')
                c++;
        }
        System.out.println("Vowels = " + v);
        System.out.println("Consonants = " + c);
    }
}
```

Converting the string to lowercase first means you only have to check five vowels instead of ten. The second condition makes sure spaces and punctuation are not counted as consonants.

### 17. Change the Case of a String

**Question:** Write a program to change the case of every letter in a string, so uppercase becomes lowercase and lowercase becomes uppercase.

```java
import java.util.*;
public class ToggleCase {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.print("Enter a string: ");
        String s = sc.nextLine();
        String result = "";
        for (int i = 0; i < s.length(); i++) {
            char ch = s.charAt(i);
            if (Character.isUpperCase(ch))
                result = result + Character.toLowerCase(ch);
            else if (Character.isLowerCase(ch))
                result = result + Character.toUpperCase(ch);
            else
                result = result + ch;
        }
        System.out.println("Result: " + result);
    }
}
```

**Sample:** "Hello World" becomes "hELLO wORLD".

## Array Programs

### 18. Bubble Sort (Ascending Order)

**Question:** Write a program to sort an array of numbers in ascending order using the bubble sort technique.

```java
import java.util.*;
public class BubbleSort {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.print("How many numbers? ");
        int n = sc.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++)
            arr[i] = sc.nextInt();
        for (int i = 0; i < n - 1; i++) {
            for (int j = 0; j < n - 1 - i; j++) {
                if (arr[j] > arr[j + 1]) {
                    int t = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = t;
                }
            }
        }
        System.out.println("Sorted: " + Arrays.toString(arr));
    }
}
```

Bubble sort compares neighbours and swaps them if they are in the wrong order, so the largest value bubbles to the end each pass. To sort in descending order, just change the greater-than sign to a less-than sign. Sorting and searching are your first real algorithms, and if they spark your curiosity, our [Java DSA course](/java-dsa-course) takes them a good deal further.

### 19. Linear Search

**Question:** Write a program to search for a number in an array using linear search and print its position.

```java
import java.util.*;
public class LinearSearch {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.print("How many numbers? ");
        int n = sc.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++)
            arr[i] = sc.nextInt();
        System.out.print("Number to search: ");
        int key = sc.nextInt();
        int pos = -1;
        for (int i = 0; i < n; i++) {
            if (arr[i] == key) {
                pos = i;
                break;
            }
        }
        if (pos == -1)
            System.out.println(key + " not found.");
        else
            System.out.println(key + " found at position " + (pos + 1));
    }
}
```

### 20. Largest and Smallest in an Array

**Question:** Write a program to find the largest and smallest element in an array of numbers.

```java
import java.util.*;
public class LargestSmallest {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.print("How many numbers? ");
        int n = sc.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++)
            arr[i] = sc.nextInt();
        int max = arr[0], min = arr[0];
        for (int i = 1; i < n; i++) {
            if (arr[i] > max) max = arr[i];
            if (arr[i] < min) min = arr[i];
        }
        System.out.println("Largest = " + max);
        System.out.println("Smallest = " + min);
    }
}
```

Starting max and min at the first element, rather than at 0, is the safe habit. It works even when every number in the array is negative.

> **Your practice plan**

> Pick one program a day, type it into BlueJ without looking, and run it on three different inputs. In three weeks you will have written all 20 from memory, which is exactly what the exam asks for.

---

## Frequently Asked Questions

**Which Java programs are most important for ICSE Class 10?**

Special-number programs (Automorphic, Neon, Spy, Disarium), palindrome and Armstrong checks, patterns using nested loops, at least one string program, an array program like bubble sort or linear search, and a menu-driven switch-case program. All 20 in this list are drawn from those recurring types.

**What is BlueJ and why does ICSE use it?**

BlueJ is a simple, beginner-friendly Java development environment. ICSE uses it because it lets students focus on writing and running Java classes without a heavy, complicated setup, which suits learners who are new to programming.

**How many marks does the program-writing part carry?**

The written paper is 100 marks over two hours. Section A is 40 marks and compulsory. Section B is 60 marks and holds the longer program-writing questions, where you get a choice of which to attempt. There is also 100 marks of Internal Assessment from lab work.

**What are special numbers in ICSE?**

Special numbers are numbers with a defining property, such as Automorphic (its square ends with the number), Neon (digits of its square add up to the number), Spy (sum of digits equals product of digits), and Disarium (digits raised to their position add up to the number). They are a favourite topic for program questions.

**Do I need to memorise these programs?**

You should be able to write them from understanding, not blind memory. Learn the shape of each group, for example how every special number breaks a value into digits, and you can rebuild any program even if the exact question is new.

**Is Java hard to learn for Class 10?**

No. The Class 10 syllabus uses a small, consistent set of ideas: input, conditions, loops, methods, arrays, and strings. Once you practise a handful of programs, the rest follow the same patterns. Regular hands-on practice matters far more than talent.

**How should I practise for the exam?**

Write each program by hand and in BlueJ, then test it with different inputs, including tricky ones like 0 or a single-digit number. Solving past papers under a timer also helps you get used to the two-hour format.

## Keep Practising, One Program at a Time

These 20 programs cover the ground that the ICSE Class X Computer Applications paper keeps returning to. Learn the idea behind each family, write them until they feel easy, and the program-writing section becomes the part you look forward to. If you want more Java practice, see our roundups of the [top 10 Java programs for school students](/blog/top-10-java-programs-for-school-students) and [Java programs for Class 8](/blog/30-best-java-programs-for-class-8-students).

When these twenty feel comfortable, two natural next steps are waiting: the full [50-program revision bank](/blog/50-java-programs-for-icse-class-10) for breadth across all seven families, and the [complete Computer Applications revision guide](/blog/icse-class-10-computer-applications-revision) for the whole-paper plan.

If you would rather learn with a teacher who checks your code and clears doubts as you go, our live classes take students aged 6 to 67 from their first line of Java to full confidence for the board exam. Explore our [Java classes](/best-java-classes-in-india) or book a free demo.

[Book a Free Java Demo Class](/contact)

### Related reading

- [Top 10 Java Programs for School Students](/blog/top-10-java-programs-for-school-students)
- [30 Best Java Programs for Class 8 Students](/blog/30-best-java-programs-for-class-8-students)
- [How to Find the HCF and LCM in Python](/blog/how-to-find-hcf-and-lcm-in-python)

---

*Source: https://learn.modernagecoders.com/blog/top-20-java-programs-for-icse-class-10/*
