ICSE Computer Applications in Sharjah: Mastering Java String Methods & 2D Array Programs

ICSE Computer Applications in Sharjah: Mastering Java String Methods & 2D Array Programs
ICSE Computer Applications in Sharjah

By EdFlik Team | December 2, 2026

For Grade 9 and Grade 10 students across Sharjah—from Al Majaz, Al Khan, and Al Nahda to Muwaileh, University City, and Al Taawun—studying ICSE Class 10 Computer Applications (CISCE Syllabus) builds practical object-oriented programming, data-handling, and algorithmic thinking skills essential for future study in Computer Science, Software Engineering, Artificial Intelligence, Data Science, Information Technology, and Electronics. Within the 100-mark external theory paper (2 hours) and 100-mark practical internal assessment, String Handling in Java and Double-Dimensional (2D) Arrays are high-scoring pillars tested through both short output/concept questions (Section A) and full menu-driven or structured Java programs (Section B).

In Sharjah's ICSE schools, many capable students understand basic loops and Scanner input yet lose valuable board marks because they use == instead of .equals() or .equalsIgnoreCase() when comparing String objects, misread the exclusive end index in substring(startIndex, endIndex), confuse .length() on a String with .length on an array, or swap row index i and column index j when computing row sums, column sums, or diagonal sums in a 2D matrix.

Earning 95–100 marks in ICSE Computer Applications requires mastering exact Java method signatures, zero-based indexing (0 to length - 1), nested loop index boundaries for rows, columns, and diagonals, and clean variable descriptions/comments in every program.

This masterclass guide covers Java String Methods & Character Extraction, Double-Dimensional (2D) Array Traversal & Matrix Operations, Complete Worked Java Programs, common CISCE mark-scheme traps.

Key Takeaways

  • Remember Zero-Based Indexing and Exact Method Signatures on Java String: Characters in a String of length L are indexed from 0 to L - 1. In substring(a, b), character extraction starts at index a (inclusive) and stops before index b (exclusive), returning b - a characters (substring(a) extracts from a to the end). Always compare string contents using equals() or equalsIgnoreCase(), never ==.
  • Distinguish .length() (Method on String) from .length (Field/Property on Arrays): A String uses str.length() with parentheses, whereas a 1D array uses arr.length without parentheses—and for a 2D array int mat[][] = new int[R][C], mat.length gives the number of rows (R) while mat[i].length gives the number of columns (C) in row i.
  • Map Matrix Positions Precisely Before Writing Nested Loops: For a square matrix m[n][n] (0-indexed 0 to n - 1):
    • Row r sum: loop c from 0 to n - 1 over m[r][c].
    • Column c sum: loop r from 0 to n - 1 over m[r][c].
    • Left (principal) diagonal: elements where r == c (m[0][0], m[1][1], ...).
    • Right (secondary) diagonal: elements where r + c == n - 1 (m[0][n-1], m[1][n-2], ...).
  • Include Clean Comments and Variable Descriptions in ICSE Programs: Following CISCE internal and board coding conventions, use clear identifier names, logical nesting, and brief comments explaining key steps.

Part 1: Essential Java String Methods for ICSE Computer Applications

In Java, String is a non-primitive (composite) class whose objects are immutable—meaning methods like toUpperCase(), toLowerCase(), trim(), and replace() return a new String unless assigned back (s = s.trim();).

Zero-based character indexing in Java Strings with indexOf and substring positions, AI generated
Zero-based character indexing in Java Strings with indexOf and substring positions.

As shown in the Java String index diagram above, each character occupies a zero-based index (0, 1, 2, ...), making index boundaries critical for charAt(), indexOf(), and substring().

Key String & Character Methods in the ICSE Syllabus

Method SignatureReturn TypeWhat It Does & ICSE Exam Watch-Out
str.length()intReturns total number of characters (including spaces).
str.charAt(int index)charReturns character at index (0 to length() - 1); throws StringIndexOutOfBoundsException if out of range.
str.indexOf(char ch) / lastIndexOf(char ch)intReturns first or last index of ch (or String), or -1 if not found.
str.substring(int beginIndex)StringExtracts substring from beginIndex through the end of str.
str.substring(int beginIndex, int endIndex)StringExtracts from beginIndex (inclusive) to endIndex - 1 (endIndex is exclusive).
str.trim()StringRemoves leading and trailing whitespace characters (spaces inside the string stay intact).
str.toUpperCase() / str.toLowerCase()StringConverts letter case and returns a new String.
str.equals(String s) / equalsIgnoreCase(String s)booleanCompares character-by-character content (case-sensitive vs. case-insensitive).
str.compareTo(String s)intCompares lexicographically (via Unicode/ASCII); returns < 0, 0, or > 0—essential for sorting String arrays.
str.replace(char oldChar, char newChar)StringReplaces all occurrences of oldChar with newChar and returns a new String.
str.startsWith(String p) / endsWith(String p)booleanChecks prefix or suffix match.

Part 2: Double-Dimensional (2D) Arrays in Java

A double-dimensional array in Java stores data in a row-and-column grid (matrix) using two indices: array[row][column].

2D array grid showing zero-based row indices and column indices, AI generated
2D array grid showing zero-based row indices and column indices.

As illustrated in the 2D array grid above, the first index selects the row and the second index selects the column, both starting at 0

               ICSE 2D ARRAY & STRING PROGRAMMING WORKFLOW
                                   |
  1. Declare &       ---> For 2D arrays: int m[][] = new int[rows][cols];
     Initialize          (or array literal {{...}, {...}}).
  2. Traverse via    ---> Outer loop for rows (i = 0 to rows - 1);
     Nested Loops        inner loop for columns (j = 0 to cols - 1).
  3. Apply Target    ---> • Row sum: fix i, sum over j.
     Condition           • Column sum: fix j, sum over i.
                         • Left diagonal: i == j.
                         • Right diagonal: i + j == n - 1.
                         • Strings: loop i = 0 to s.length() - 1 with charAt(i).
  4. Format Output   ---> Print matrices cleanly in grid form (using \t or spaces)
     Clearly             and print clear labeled results.

Standard 2D Array Operations Tested in ICSE

OperationLoop / Condition PatternTypical Exam Requirement
Accept & Display MatrixOuter for (int i = 0; i < r; i++), inner for (int j = 0; j < c; j++)Input elements via Scanner and print row-by-row in matrix layout (System.out.print(m[i][j] + "\t") then System.out.println()).
Row Sum & Column Sum

Row i sum: sumRow += m[i][j];


Col j sum: sumCol += m[i][j]

Compute sum of each row or a specific row/column.
Left & Right Diagonal Sum (Square matrix n x n)

Left diagonal: if (i == j) leftSum += m[i][j];


Right diagonal: if (i + j == n - 1) rightSum += m[i][j];

Note: if n is odd, the center cell (n/2, n/2) satisfies both i == j and i + j == n - 1.

Part 3: Complete Worked Java Programs (ICSE Board Style)

Worked Program 1: Counting Vowels, Consonants & Checking Palindrome in a String

Problem: Write a Java program to accept a word/string from the user, display the count of vowels and consonants (ignoring spaces/non-letters), and check whether the string is a palindrome (ignoring case).

Java

import java.util.Scanner;

public class StringAnalyzer {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.print("Enter a string: ");
        String input = sc.nextLine().trim();

        String lower = input.toLowerCase();
        String reversed = "";
        int vowels = 0, consonants = 0;

        for (int i = 0; i < lower.length(); i++) {
            char ch = lower.charAt(i);
            // Build reversed string for palindrome check
            reversed = ch + reversed;

            if (Character.isLetter(ch)) {
                if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u') {
                    vowels++;
                } else {
                    consonants++;
                }
            }
        }

        System.out.println("Vowels: " + vowels);
        System.out.println("Consonants: " + consonants);

        if (lower.equals(reversed)) {
            System.out.println(input + " is a Palindrome.");
        } else {
            System.out.println(input + " is NOT a Palindrome.");
        }
        sc.close();
    }
}

Worked Program 2: 2D Square Matrix Row, Column & Diagonal Sums

Problem: Write a Java program to accept elements into an N x N integer double-dimensional array (N <= 10), print the matrix in grid format, and calculate the sum of the left diagonal and sum of the right diagonal.

Java

import java.util.Scanner;

public class MatrixDiagonalSum {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.print("Enter matrix size N: ");
        int n = sc.nextInt();

        int[][] mat = new int[n][n];
        System.out.println("Enter " + (n * n) + " integers:");

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                mat[i][j] = sc.nextInt();
            }
        }

        int leftDiagSum = 0;
        int rightDiagSum = 0;

        System.out.println("\nMatrix:");
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                System.out.print(mat[i][j] + "\t");
                if (i == j) {
                    leftDiagSum += mat[i][j];
                }
                if (i + j == n - 1) {
                    rightDiagSum += mat[i][j];
                }
            }
            System.out.println();
        }

        System.out.println("Left Diagonal Sum: " + leftDiagSum);
        System.out.println("Right Diagonal Sum: " + rightDiagSum);
        sc.close();
    }
}

Part 4: Top 4 Exam Traps That Cost Sharjah ICSE Computer Applications Students Marks

  1. Using str1 == str2 Instead of str1.equals(str2): In Java, == checks reference equality, whereas .equals() or .equalsIgnoreCase() checks actual character sequence equality.
  2. Off-by-One Errors on i <= str.length() in charAt(i): Because indices run from 0 to length() - 1, using <= str.length() throws an out-of-bounds runtime error at index length().
  3. Forgetting String Immutability: Calling "hello".toUpperCase(); without storing or printing the returned string leaves the original variable unchanged.
  4. Swapping i and j on Column Sums or Right Diagonals: Always double-check whether the outer loop controls rows (i) or columns (j) and verify that i + j == n - 1 matches the top-right to bottom-left diagonal of an n x n grid.

For 1-on-1 online tutoring to master ICSE Computer Applications Java string handling, 2D arrays, sorting and searching algorithms, OOP classes and constructors, and board exam coding in Sharjah, book a session on EdFlik.

Frequently Asked Questions (FAQs)

Q1: What is the difference between substring(a) and substring(a, b) in Java?

Ans: str.substring(a) returns characters from index a to the end of the string, whereas str.substring(a, b) returns characters starting at index a up to index b - 1 (b is exclusive).

Q2: How do you find the right diagonal of an N x N 2D array in Java?

Ans: In a zero-indexed N x N array arr, elements on the right (secondary) diagonal satisfy the index condition row + col == N - 1.

Q3: How can Sharjah students prepare effectively for ICSE Java String and 2D array questions?

Ans: Trace sample inputs dry-run style on paper (charAt, substring, indexOf, loop indices), practice writing full programs from scratch without autocomplete, and check edge cases such as empty/trimmed strings and odd vs. even matrix sizes.

ICSE Computer Applications Tutor Online Guide
What UAE parents should check in an ICSE Computer Applications tutor: syllabus knowledge, programming practice and exam technique. Online one-to-one.
Computer Science & Coding Tutor Dubai UAE 2026 — Python, Java, AP & IGCSE
Best Computer Science & Coding tutor in Dubai & UAE. Expert 1-on-1 lessons in Python, Java, IGCSE 0478, A-Level, and AP CS. Free trial class.
A-Level Computer Science: NEA Project & Theory Papers Guide
How A-Level Computer Science is assessed on AQA, OCR and Cambridge 9618, how to plan and document the NEA programming project, and how to prepare for…
AQA GCSE Computer Science Dubai: SQL Queries & Topologies | EdFlik
Master AQA GCSE Computer Science (8525) in Dubai! Complete guide to SQL queries, star vs mesh network topologies, worked exam questions & FAQs.