Solved 2025 Specimen Paper ICSE Class 10 Computer Applications
Solutions for Computer Applications, Class 10, ICSE
Section A
30 questionsAnswer:
Two Dimensional array with 4 rows and 5 columns
Reason — A two-dimensional array is like a grid or table with rows and columns. The image shows a table with 4 rows and 5 columns.
Answer:
Platform Independent
Reason — The feature of "Platform Independence" allows Java compiled code (bytecode) to run on any operating system. This is achieved through the Java Virtual Machine (JVM), which interprets the bytecode and executes it on the specific platform.
Answer:
static
Reason — In Java, keywords are reserved words that have a specific meaning and purpose in the language. Keywords must always be written in lowercase. Analysing the given options:
If: Incorrect because Java keywords are case-sensitive, and the correct keyword isif(in lowercase).BOOLEAN: Incorrect because the keyword in Java isboolean(in lowercase).static: Correct.staticis a valid Java keyword used to declare static methods, variables, or blocks.Switch: Incorrect because the correct keyword isswitch(in lowercase).
Answer:
4.0
Reason — Let's evaluate the expression step by step:
System.out.println(Math.ceil(6.4) + Math.floor(-1 - 2));Step 1: Evaluate Math.ceil(6.4)
- The
ceilmethod rounds a number up to the nearest integer. Math.ceil(6.4)→7.0(asceilreturns adouble).
Step 2: Evaluate -1 - 2
-1 - 2 = -3
Step 3: Evaluate Math.floor(-3)
Math.floor(-3): Thefloormethod rounds a number down to the nearest integer.Math.floor(-3)→-3.0(asflooralso returns adouble).
Step 4: Add the Results
Math.ceil(6.4)+Math.floor(-3)→7.0 + (-3.0)- Result =
4.0
Answer:
supports floating point constants
Reason — The switch statement does not support float or double constants as case labels. It supports byte, short, int, char, String and enum.
Answer:
130
Reason — The given array is:
char ch[] = {'A', 'E', 'I', 'O', 'U'};Step-by-Step Execution:
1. ch[0]:
- The element at index
0of the array is 'A'.
2. Character Multiplication in Java:
- In Java, a
charis treated as a numeric value based on its ASCII code when used in arithmetic operations. - The ASCII value of 'A' is 65.
3. ch[0] * 2:
- Substituting
ch[0]with its ASCII value:
65 * 2 = 1304. Output:
System.out.println(ch[0] * 2);will print 130.
Answer:
for (int i=11;i<=30;i+=2)
Reason — To execute a loop 10 times, the total number of iterations should match 10, based on the condition and increment values. Let's analyse each option:
1. for (int i = 11; i <= 30; i += 2)
- The loop starts at
11and increments by2. - The sequence is:
11, 13, 15, 17, 19, 21, 23, 25, 27, 29. - This loop executes 10 times.
2. for (int i = 11; i <= 30; i += 3)
- The loop starts at
11and increments by3. - The sequence is:
11, 14, 17, 20, 23, 26, 29. - This loop executes only 7 times, so it is incorrect.
3. for (int i = 11; i < 20; i++)
- The loop starts at
11and increments by1. - The sequence is:
11, 12, 13, 14, 15, 16, 17, 18, 19. - This loop executes only 9 times, so it is incorrect.
4. for (int i = 11; i <= 21; i++)
- The loop starts at
11and increments by1. - The sequence is:
11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21. - This loop executes 11 times, so it is incorrect.
Answer:
x[49]=100
Reason — In Java, arrays use zero-based indexing, meaning the first element of the array is at index 0. For an array with n elements, the last element is at index n - 1.
Given a single-dimensional array with 50 elements, the indices range from 0 to 49. Thus, the correct index for the last element is 49.
Answer:
boolean compute (int a, int b)
Reason — Let's analyse the given options:
void compute (int a, int b)— Incorrect becausevoidmeans the method does not return any value, but the question requires the method to returntrue/false.boolean compute (int a, int b)— Correct because it returns abooleanvalue (trueorfalse) and accepts two integer arguments.Boolean compute (int a, b)— Incorrect due to syntax error (int bis not fully declared). Also,Booleanis a wrapper class, not a primitiveboolean.int compute (int a, int b)— Incorrect because the return type isint, notboolean.
Answer:
return
Reason — The return statement in Java is used to bring the control back to the calling method. If the method has a return type other than void, the return statement also passes back a value to the calling method.
Answer:
false
Reason — In Java, the default value of a variable depends on its data type. For a boolean variable, the default value is false (in lowercase). This is because Java uses the primitive boolean type, which has only two possible values: true or false.
Answer:
Character.toUpperCase( char )
Reason — The method Character.toUpperCase(char) is used to convert a single lowercase character to its uppercase equivalent. It belongs to the Character class in Java.
Assertion (A): Integer class can be used in the program without calling a package.
Reason (R): It belongs to the default package java.lang.
- Both Assertion (A) and Reason (R) are true and Reason (R) is a correct explanation of Assertion (A)
- Both Assertion (A) and Reason (R) are true and Reason (R) is not a correct explanation of Assertion(A)
- Assertion (A) is true and Reason (R) is false
- Assertion (A) is false and Reason (R) is true
Answer:
Both Assertion (A) and Reason (R) are true and Reason (R) is a correct explanation of Assertion (A)
Reason — The Integer class can indeed be used in a program without explicitly importing any package. This is because it is part of the java.lang package, which is automatically imported in every Java program by default.
Answer:
Both A and C
Reason — The student's code x = +2; is incorrect because it doesn't actually increment x by 2. Instead, it simply assigns the value +2 to x.
The correct way to increment the value of x by 2 is:
Option A:
x += 2;
This is shorthand forx = x + 2;and correctly incrementsxby 2.Option C:
x = x + 2;
This is the full, explicit version of incrementingxby 2. It is also correct.
Option B: x = 2;
This assigns 2 to x, which is not incrementing its value. Hence, this is incorrect.
Answer:
s.length
Reason — In Java, arrays have a property called length, which gives the total number of elements in the array. This applies to any type of array, including arrays of Strings.
For a string array String s[], the correct way to get the number of elements is:
s.lengthAnalysing other options:
s.length():- Incorrect. The
length()method is used for String objects to get the number of characters in a String, not for arrays.
- Incorrect. The
length(s):- Incorrect. This is not a valid syntax in Java.
len(s):- Incorrect. Java does not have a function called
len()for arrays or strings.
- Incorrect. Java does not have a function called
Consider the following program segment in which the statements are jumbled, choose the correct order of statements to swap two variables using the third variable.
void swap(int a, int b)
{
a = b; → (1)
b = t; → (2)
int t = 0; → (3)
t = a; → (4)
}- (1) (2) (3) (4)
- (3) (4) (1) (2)
- (1) (3) (4) (2)
- (2) (1) (4) (3)
Answer:
(3) (4) (1) (2)
Reason — To swap two variables a and b using a third variable t, the correct sequence of statements is:
Step 1: Declare and initialize the third variable t.
int t = 0; // (3)Step 2: Assign the value of a to t.
t = a; // (4)Step 3: Assign the value of b to a.
a = b; // (1)Step 4: Assign the value of t (original value of a) to b.
b = t; // (2)Correct Order:
int t = 0; // (3)
t = a; // (4)
a = b; // (1)
b = t; // (2)Assertion (A): An argument is a value that is passed to a method when it is called.
Reason (R): Variables which are declared in a method prototype to receive values are called actual parameters
- Both Assertion (A) and Reason (R) are true and Reason (R) is a correct explanation of Assertion (A)
- Both Assertion (A) and Reason (R) are true and Reason (R) is not a correct explanation of Assertion(A)
- Assertion (A) is true and Reason (R) is false
- Assertion (A) is false and Reason (R) is true
Answer:
Assertion (A) is true and Reason (R) is false
Explanation — Arguments are the actual values passed to a method when it is invoked. For example:
void exampleMethod(int x) { ... }
exampleMethod(5); // Here, 5 is the argument.Hence, Assertion (A) is true.
The variables declared in a method prototype (or header) to receive values are called formal parameters, not actual parameters. For example:
void exampleMethod(int x) { // x is the formal parameter
System.out.println(x);
}
exampleMethod(5); // 5 is the actual parameterHence, Reason (R) is false.
Answer:
The code can be rewritten using a single if statement as follows:
if(code == 'g' || code == 'G')
System.out.println("GREEN");Explanation:
- The logical OR operator (
||) is used to check ifcodeis either'g'or'G'. - If either condition is true, the statement
System.out.println("GREEN");will execute. This simplifies the multipleif-elseblocks into a singleifstatement.
Answer:
a = 4, b = 6
Explanation:
The given expression is evaluated as follows:
b*=a++ - ++b + ++a
b = b * (a++ - ++b + ++a) [a=2, b=3]
b = 3 * (2 - 4 + 4) [a=4, b=4]
b = 3 * 2
b = 6
Answer:
Statement having the error is:
boolean x = true;
Corrected code:
int x = 1; // Change boolean to int
switch(x)
{
case 1: System.out.println("WIN"); break;
case 2: System.out.println("LOOSE");
}Explanation:
The error occurs because the switch statement in Java does not support the boolean data type. A switch expression must be one of the following types:
int,byte,short,char,String, or anenum.
Replacing boolean x = true; with int x = 1; ensures that the switch statement now uses a valid data type (int). Assigning x = 1 makes the case 1 to execute printing WIN as the output.
Answer:
The loop executes two times.
Output
20
22
Explanation:
Step-by-Step Execution of the Code
Initial Value of x:x = 10
Iteration 1:System.out.println(x++ * 2);
x++→ Use the current value ofx(10), then incrementxto 11.- Output:
10 * 2 = 20
if (x % 3 == 0):
x = 11, so11 % 3 = 2→ Condition isfalse.
Iteration 2:System.out.println(x++ * 2);
x++→ Use the current value ofx(11), then incrementxto 12.- Output:
11 * 2 = 22
if (x % 3 == 0):
x = 12, so12 % 3 = 0→ Condition istrue.
break;
- The
breakstatement exits the loop.
Answer:
The outputs are:
(a) true
(b) -1
Explanation:
Given Strings:
String x = "Galaxy";
String y = "Games";(a) System.out.println(x.charAt(0) == y.charAt(0));
x.charAt(0): Retrieves the character at index0ofx→'G'.y.charAt(0): Retrieves the character at index0ofy→'G'.Comparison:
'G' == 'G'→true.
(b) System.out.println(x.compareTo(y));
x.compareTo(y): Comparesx("Galaxy") withy("Games") lexicographically (character by character based on Unicode values). The comparison is based on the first differing character:'G' == 'G'→ Equal, move to the next characters.'a' == 'a'→ Equal, move to the next characters.'l' == 'm'→'l'(Unicode 108) is less than'm'(Unicode 109).
Result:
x.compareTo(y)→108 - 109 = -1.
Answer:
X b
Step-by-Step Execution:
char ch = 'B';
chis assigned the character'B'.
char chr = Character.toLowerCase(ch);
Character.toLowerCase(ch)converts'B'to its lowercase equivalent'b'.chr = 'b'.
int n = (int) chr - 10;
(int) chrconverts the character'b'to its ASCII value.- ASCII value of
'b'is 98. n = 98 - 10 = 88.
System.out.println((char) n + "\t" + chr);
(char) n: Converts the integer88back to a character.- ASCII value
88corresponds to the character'X'.
- ASCII value
+ "\t" +adds a tab space between the characters.chr: The value ofchris'b'.
A student is trying to convert the string present in x to a numerical value, so that he can find the square root of the converted value. However the code has an error. Name the error (syntax / logical / runtime). Correct the code so that it compiles and runs correctly.
String x= "25";
int y=Double.parseDouble(x);
double r=Math.sqrt(y);
System.out.println(r);Answer:
Syntax error in the line:int y=Double.parseDouble(x);
Corrected code:
String x= "25";
double y=Double.parseDouble(x); //int changed to double
double r=Math.sqrt(y);
System.out.println(r);Explanation:
The error is a syntax error because the method Double.parseDouble(x) returns a double, but the code is trying to assign it to an int variable without proper casting, which is not allowed in Java.
Consider the following program segment and answer the questions below:
class calculate
{
int a; double b;
calculate()
{
a=0;
b=0.0;
}
calculate(int x, double y)
{
a=x;
b=y;
}
void sum()
{
System.out.println(a*b);
}}Name the type of constructors used in the above program segment?
Answer:
The type of constructors used in the above program segment are:
- Default constructor
- Parameterized constructor
Explanation:
The types of constructors used in the given program are:
1. Default Constructor:
calculate() {
a = 0;
b = 0.0;
}- A default constructor is a constructor that does not take any parameters.
- It initializes the instance variables
aandbwith default values (0and0.0respectively).
2. Parameterized Constructor:
calculate(int x, double y) {
a = x;
b = y;
}- A parameterized constructor is a constructor that takes arguments (
int xanddouble yin this case). - It allows for initializing the instance variables
aandbwith specific values provided during object creation.
Answer:
(a) The position of 34 is x[2][0]
(b) x[2][3] + x[1][2] = 9 + 8 = 17
Explanation:
(a) Position of 34
- The array
xis a 2D array, where elements are accessed using row and column indices. - The element
34is located in the 3rd row and 1st column. - In zero-based indexing:
- Row index:
2 - Column index:
0
- Row index:
Position: x[2][0]
(b) Result of x[2][3] + x[1][2]
Step 1: Locate x[2][3]
x[2][3]refers to the element in the 3rd row and 4th column.- Value at
x[2][3]=9.
Section B
6 questionsDefine a class with the following specifications:
Class name: Bank
Member variables:
double p — stores the principal amount
double n — stores the time period in years
double r — stores the rate of interest
double a — stores the amount
Member methods:
void accept () — input values for p and n using Scanner class methods only.
void calculate () — calculate the amount based on the following conditions:
| Time in (Years) | Rate % |
|---|---|
| Upto 1⁄2 | 9 |
| > 1⁄2 to 1 year | 10 |
| > 1 to 3 years | 11 |
| > 3 years | 12 |
void display () — display the details in the given format.
Principal Time Rate Amount
XXX XXX XXX XXX
Write the main method to create an object and call the above methods.
import java.util.Scanner;
public class Bank
{
private double p;
private double n;
private double r;
private double a;
void accept() {
Scanner in = new Scanner(System.in);
System.out.print("Enter principal amount: ");
p = in.nextDouble();
System.out.print("Enter time period in years: ");
n = in.nextDouble();
}
void calculate() {
if (n <= 0.5) {
r = 9;
} else if (n <= 1) {
r = 10;
} else if (n <= 3) {
r = 11;
} else {
r = 12;
}
a = p * Math.pow(1 + (r / 100), n);
}
void display() {
System.out.println("Principal\tTime\tRate\tAmount");
System.out.println(p + "\t" + n + "\t" + r + "\t" + a);
}
public static void main(String args[]) {
Bank b = new Bank();
b.accept();
b.calculate();
b.display();
}
}
Answer:
Define a class to search for a value input by the user from the list of values given below. If it is found display the message "Search successful", otherwise display the message "Search element not found" using Binary search technique.
5.6, 11.5, 20.8, 35.4, 43.1, 52.4, 66.6, 78.9, 80.0, 95.5.
import java.util.Scanner;
public class KboatBinarySearch
{
void search(double[] arr, double key) {
int low = 0;
int high = arr.length - 1;
boolean found = false;
while (low <= high) {
int mid = (low + high) / 2;
if (arr[mid] == key) {
found = true;
break;
} else if (arr[mid] < key) {
low = mid + 1;
} else {
high = mid - 1;
}
}
if (found) {
System.out.println("Search successful");
} else {
System.out.println("Search element not found");
}
}
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
double[] values = {5.6, 11.5, 20.8, 35.4, 43.1, 52.4, 66.6, 78.9, 80.0, 95.5};
System.out.print("Enter the value to search: ");
double key = in.nextDouble();
KboatBinarySearch obj = new KboatBinarySearch();
obj.search(values, key);
}
}

Answer:
Define a class to accept a string and convert the same to uppercase, create and display the new string by replacing each vowel by immediate next character and every consonant by the previous character. The other characters remain the same.
Example:
Input : #IMAGINATION@2024
Output : #JLBFJMBSJPM@2024
import java.util.Scanner;
public class KboatStringConvert
{
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
System.out.print("Enter a string: ");
String str = in.nextLine();
str = str.toUpperCase();
int l = str.length();
String res = "";
for (int i = 0; i < l; i++) {
char ch = str.charAt(i);
if ("AEIOU".indexOf(ch) != -1) {
res += (char)(ch + 1);
}
else if (Character.isLetter(ch)) {
res += (char)(ch - 1);
}
else {
res += ch;
}
}
System.out.println("Output String:");
System.out.println(res);
}
}
Answer:
Define a class to accept values into 4x4 array and find and display the sum of each row.
Example:
A[][]={{1,2,3,4},{5,6,7,8},{1,3,5,7},{2,5,3,1}}
Output:
sum of row 1 = 10 (1+2+3+4)
sum of row 2 = 26 (5+6+7+8)
sum of row 3 = 16 (1+3+5+7)
sum of row 4 = 11 (2+5+3+1)
import java.util.Scanner;
public class KboatDDARowSum
{
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
int arr[][] = new int[4][4];
System.out.println("Enter 4x4 DDA elements:");
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
arr[i][j] = in.nextInt();
}
}
for (int i = 0; i < 4; i++) {
int rowSum = 0;
for (int j = 0; j < 4; j++) {
rowSum += arr[i][j];
}
System.out.println("Sum of Row" + (i+1)
+ " = " + rowSum);
}
}
}
Answer:
Define a class to accept a number and check whether it is a SUPERSPY number or not. A number is called SUPERSPY if the sum of the digits equals the number of the digits.
Example1:
Input: 1021
output: SUPERSPY number [SUM OF THE DIGITS = 1+0+2+1 = 4,
NUMBER OF DIGITS = 4 ]
Example2:
Input: 125
output: Not an SUPERSPY number [1+2+5 is not equal to 3]
import java.util.Scanner;
public class KboatSuperSpy
{
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
System.out.print("Enter a number: ");
int num = in.nextInt();
int sum = 0;
int dc = 0;
int orgNum = num;
while (num > 0) {
int d = num % 10;
sum += d;
dc++;
num /= 10;
}
if (sum == dc) {
System.out.println(orgNum + " is a SUPERSPY number");
}
else {
System.out.println(orgNum + " is not a SUPERSPY number");
}
}
}

Answer:
Define a class to overload the method display() as follows:
void display(): To print the following format using nested loop.
1 2 1 2 1
1 2 1 2 1
1 2 1 2 1
void display (int n, int m) : To print the quotient of the division of m and n if m is greater than n otherwise print the sum of twice n and thrice m.
double display (double a, double b, double c) — to print the value of z where
public class KboatOverloadDisplay
{
void display() {
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 5; j++) {
if (j % 2 == 0) {
System.out.print("1 ");
} else {
System.out.print("2 ");
}
}
System.out.println();
}
}
void display(int n, int m) {
if (m > n) {
double q = m / n;
System.out.println("Quotient: " + q);
} else {
int sum = 2 * n + 3 * m;
System.out.println("Sum: " + sum);
}
}
double display(double a, double b, double c) {
double p = (a + b) / c;
double q = a + b + c;
double z = p * q;
System.out.println("Z = " + z);
return z;
}
}






