ICSE Computer Applications in Sharjah: Mastering Java String Methods & 2D Array Programs
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 aStringof lengthLare indexed from0toL - 1. Insubstring(a, b), character extraction starts at indexa(inclusive) and stops before indexb(exclusive), returningb - acharacters (substring(a)extracts fromato the end). Always compare string contents usingequals()orequalsIgnoreCase(), never==. - Distinguish
.length()(Method onString) from.length(Field/Property on Arrays): AStringusesstr.length()with parentheses, whereas a 1D array usesarr.lengthwithout parentheses—and for a 2D arrayint mat[][] = new int[R][C],mat.lengthgives the number of rows (R) whilemat[i].lengthgives the number of columns (C) in rowi. - Map Matrix Positions Precisely Before Writing Nested Loops: For a square matrix
m[n][n](0-indexed0ton - 1):- Row
rsum: loopcfrom0ton - 1overm[r][c]. - Column
csum: looprfrom0ton - 1overm[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], ...).
- Row
- 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();).
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 Signature | Return Type | What It Does & ICSE Exam Watch-Out |
str.length() | int | Returns total number of characters (including spaces). |
str.charAt(int index) | char | Returns character at index (0 to length() - 1); throws StringIndexOutOfBoundsException if out of range. |
str.indexOf(char ch) / lastIndexOf(char ch) | int | Returns first or last index of ch (or String), or -1 if not found. |
str.substring(int beginIndex) | String | Extracts substring from beginIndex through the end of str. |
str.substring(int beginIndex, int endIndex) | String | Extracts from beginIndex (inclusive) to endIndex - 1 (endIndex is exclusive). |
str.trim() | String | Removes leading and trailing whitespace characters (spaces inside the string stay intact). |
str.toUpperCase() / str.toLowerCase() | String | Converts letter case and returns a new String. |
str.equals(String s) / equalsIgnoreCase(String s) | boolean | Compares character-by-character content (case-sensitive vs. case-insensitive). |
str.compareTo(String s) | int | Compares lexicographically (via Unicode/ASCII); returns < 0, 0, or > 0—essential for sorting String arrays. |
str.replace(char oldChar, char newChar) | String | Replaces all occurrences of oldChar with newChar and returns a new String. |
str.startsWith(String p) / endsWith(String p) | boolean | Checks 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].
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
| Operation | Loop / Condition Pattern | Typical Exam Requirement |
| Accept & Display Matrix | Outer 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 Col | Compute sum of each row or a specific row/column. |
Left & Right Diagonal Sum (Square matrix n x n) | Left diagonal: Right diagonal: | 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
- Using
str1 == str2Instead ofstr1.equals(str2): In Java,==checks reference equality, whereas.equals()or.equalsIgnoreCase()checks actual character sequence equality. - Off-by-One Errors on
i <= str.length()incharAt(i): Because indices run from0tolength() - 1, using<= str.length()throws an out-of-bounds runtime error at indexlength(). - Forgetting
StringImmutability: Calling"hello".toUpperCase();without storing or printing the returned string leaves the original variable unchanged. - Swapping
iandjon Column Sums or Right Diagonals: Always double-check whether the outer loop controls rows (i) or columns (j) and verify thati + j == n - 1matches the top-right to bottom-left diagonal of ann x ngrid.
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.



