Solved 2024 Specimen Paper ICSE Class 10 Computer Applications
Solved 2024 Specimen Paper ICSE Class 10 Computer Applications
Section A
Question 1(i)
1. Encapsulation
2. Inheritance
3. Abstraction
4. Polymorphism
Answer
Inheritance
Reason — The given picture shows the relationship of a parent (father) and child. Just like a
child inherits some characteristics from his parents, inheritance enables new classes (derived
class) to receive or inherit the properties and methods of existing classes (base class).
Question 1(ii)
1. relational
2. logical
3. arithmetic
4. assignment
Answer
relational
Reason — Relational expressions are constructed using relational operators — equal to
( == ), not equal to ( != ), less than ( < ), less than equal to ( <= ), greater than ( > ), greater
than equal to ( >= )
Question 1(iii)
Ternary operator is a:
1. logical operator
2. arithmetic operator
3. relational operator
4. conditional operator
Answer
conditional operator
Reason — Ternary operator is a conditional operator as it evaluates the given condition. Its
syntax is as follows:
condition? expression 1 : expression 2
If the condition is true then result of ternary operator is the value of expression 1. Otherwise
the result is the value of expression 2.
Question 1(iv)
When primitive data type is converted to a corresponding object of its class, it is called:
1. Boxing
2. Unboxing
3. explicit type conversion
4. implicit type conversion
Answer
Boxing
Reason — Boxing is the conversion of primitive data type into an object of its corresponding
wrapper class.
Question 1(v)
1. 20 bytes
2. 60 bytes
3. 40 bytes
4. 120 bytes
Answer
20 bytes
Reason — A char data type occupies '2' bytes in the memory. Thus, 10 char type elements
occupy (10 x 2) = 20 bytes in memory.
Question 1(vi)
1. nextInt()
2. nextDouble()
3. next()
4. nextInteger()
Answer
nextDouble()
Reason — The nextDouble() function reads the next token entered by the user as a double
value.
Question 1(vii)
1. every
2. all
3. case
4. each
Answer
case
Question 1(viii)
1. 9.0
2. 11.0
3. 10.0
4. 11
Answer
11.0
⇒ 7 + 4.0
Math.round(6.6) + Math.ceil(3.4)
⇒ 11.0
Math.round() rounds off its argument to the nearest mathematical integer and returns its value
as an int or long type. Math.ceil method returns the smallest double value that is greater than
or equal to the argument and is equal to a mathematical integer. In the addition operation, the
type of result is promoted to a double as one operand is double. Hence, the result is 11.0.
Question 1(ix)
1. logical
2. no error
3. runtime
4. syntax
Answer
syntax
Reason — The given statement is missing a terminator ( ; ) at the end. Thus, it has a syntax
error.
Question 1(x)
1. X[4]
2. X[5]
3. X[3]
4. X[0]
Answer
X[4]
Reason — Array indexes start from 0. So, X[4] refers to the 5th element of the array.
Question 1(xi)
1. mark
2. emark
3. marka
4. able
Answer
able
Question 1(xii)
Which of the following is the wrapper class for the data type char?
1. String
2. Char
3. Character
4. Float
Answer
Character
Reason — Character is the wrapper class for the data type char.
Question 1(xiii)
1. java.lang
2. java.util
3. java.io
4. java.awt
Answer
java.lang
Question 1(xiv)
1. Inheritance
2. Polymorphism
3. Abstraction
4. Encapsulation
Answer
Polymorphism
Question 1(xv)
1. Only i
2. i and iii
3. ii and iv
4. i and ii
Answer
Only i
Reason — Integer constants represent whole number values only. Thus, 4 is an integer
constant. 4.0 is a double constant, 4.3f is a float constant while "four" is a String constant.
Question 1(xvi)
The method compareTo() returns ............... when two strings are equal and in lowercase :
1. true
2. 0
3. 1
4. false
Answer
Reason — compareTo() method compares two strings lexicographically and returns the
difference between the ASCII values of the first differing characters in the strings. Here, the
strings are equal so the difference is 0.
Question 1(xvii)
Assertion (A): In Java, statements written in lower case letter or upper case letter are treated
as the same.
1. Both Assertion (A) and Reason (R) are true and Reason (R) is a correct explanation of
Assertion (A)
2. Both Assertion (A) and Reason (R) are true and Reason (R) is not a correct
explanation of Assertion (A)
3. Assertion (A) is true and Reason (R) is false
4. Assertion (A) is false and Reason (R) is true
Answer
Reason — In Java, statements written in lower case letter or upper case letter are treated
differently as Java is a case sensitive language.
Question 1(xviii)
A class encapsulate Data Members that contains the information necessary to represent the
class and Member methods that perform operations on the data member.
Answer
Reason — A class encapsulates state and behavior by combining data and functions into a
single unit. The state of an object is represented by its member variables and behaviour is
represented by member methods.
Question 1(xix)
Reason (R): The original value of variable does not change as operation is performed on
copied values.
1. Both Assertion (A) and Reason (R) are true and Reason (R) is a correct explanation of
Assertion (A)
2. Both Assertion (A) and Reason (R) are true and Reason (R) is not a correct
explanation of Assertion (A)
3. Assertion (A) is true and Reason (R) is false
4. 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 — Call by value is known as pure method as it does not modify the value of original
variables. The original value of variable does not change as operation is performed on copied
values.
Question 1(xx)
System.out.print(Character.toLowerCase('1'));
1. 0
2. 1
3. A
4. true
Answer
Question 2(i)
Answer
Math.pow((p + q) , 2)
Question 2(ii)
Output
10
Explanation
x = x++ + ++x + x
x = 2 + ++x + x (x = 3)
x=2+4+x (x = 4)
x=2+4+4 (x = 4)
x = 10
Question 2(iii)
The following code segment should print "You can go out" if you have done your homework
(dh) and cleaned your room (cr). However, the code has errors. Fix the code so that it
compiles and runs correctly.
boolean dh = True;
boolean cr= true;
if (dh && cr)
System.out.println("You cannot go out");
else
System.out.println("You can go out");
Answer
boolean dh = true;
boolean cr= true;
if (dh && cr)
System.out.println("You can go out");
else
System.out.println("You cannot go out");
Explanation
Question 2(iv)
Sam executes the following program segment and the answer displayed is zero irrespective of
any non zero values are given. Name the error. How the program can be modified to get the
correct answer?
Logical error.
Modified program:
Explanation
a = 1/2 * b * h;
a = 0 * b * h; (1/2 being integer division gives the result as 0)
a = 0 (Since anything multiplied by 0 will be 0)
To avoid this error, we can replace '1/2' with '1.0/2'. Now the expression will be evaluated as
follows:
a = 1.0/2 * b * h;
a = 0.5 * b * h; (The floating-point division will result in result as as 0.5)
This will give the correct result for the given code.
Question 2(v)
How many times will the following loop execute? What value will be returned?
int x = 2;
int y = 50;
do{
++x;
y -= x++;
}
while(x <= 10);
return y;
Answer
The loop will execute 5 times and the value returned is 15.
Explanation
Iteration X Y Remark
2 50 Initial values
1 3 47 x = 4 (3 + 1), y = 47 (50 - 3)
2 5 42 x = 6 (5 + 1), y = 42 (47 - 5)
3 7 35 x = 8 (7 + 1), y = 35 (42 - 7)
4 9 26 x = 10 (8 + 1), y = 26 (35 - 9)
Question 2(vi)
(a) "ARTIFICIAL".indexOf('I')
Answer
(a)
Output
Explanation
indexOf() returns the index of the first occurrence of the specified character within the string
or -1 if the character is not present. First occurrence of 'I' in "ARTIFICIAL" is at index 3 (a
string begins at index 0).
(b)
Output
13
Explanation
trim() removes all leading and trailing space from the string and length() returns the length of
the string i.e., the number of characters present in the string. Thus, the output is 13.
Question 2(vii)
Answer
1. break statement
2. continue statement
Question 2(viii)
String a = "20";
String b = "23";
int p = Integer.parseInt(a);
int q = Integer.parseInt(b);
System.out.print(a + "*" + b);
Answer
Output
20*23
Explanation
Integer.parseInt() method will convert the strings a and b to their corresponding numerical
integers — 20 and 23. In the statement, System.out.print(a + "*" + b); a, b,
and "*" are strings so + operator concatenates them and prints 20*23 as the output.
Question 2(ix)
When there is no explicit initialization, what are the default values set for variables in the
following cases?
Answer
(a) 0
(b) null
Question 2(x)
Place all elements of P array and Q array in the array R one after the other.
Answer
Section B
Question 3
Member variables:
String name: name of the item purchased
double price: Price of the item purchased
Member methods:
void accept(): Accept the name and the price of the item using the methods of Scanner class.
void calculate(): To calculate the net amount to be paid by a customer, based on the following
criteria:
Price Discount
void display(): To display the name of the item and the net amount to be paid.
Write the main method to create an object and call the above methods.
import java.util.Scanner;
public class Eshop
{
private String name;
private double price;
private double disc;
private double amount;
Output
Question 4
Define a class to accept values in integer array of size 10. Sort them in an ascending order
using selection sort technique. Display the sorted array.
import java.util.Scanner;
int t = arr[i];
arr[i] = arr[idx];
arr[idx] = t;
}
System.out.println("Sorted Array:");
for (int i = 0; i < 10; i++)
{
System.out.print(arr[i] + " ");
}
}
}
Output
Question 5
Define a class to accept a string and convert it into uppercase. Count and display the number
of vowels in it.
Input: robotics
Output: ROBOTICS
Number of vowels: 3
import java.util.Scanner;
Output
Question 6
Define a class to accept values into a 3 × 3 array and check if it is a special array. An array is
a special array if the sum of the even elements = sum of the odd elements.
Example:
A[ ][ ]={{ 4 ,5, 6}, { 5 ,3, 2}, { 4, 2, 5}};
Sum of even elements = 4 + 6 + 2 + 4 + 2 = 18
Sum of odd elements = 5 + 5 + 3 + 5 = 18
import java.util.Scanner;
Output
Question 7
Define a class to accept a 3 digit number and check whether it is a duck number or not.
Note: A number is a duck number if it has zero in it.
Example 1:
Input: 2083
Output: Invalid
Example 2:
Input: 103
Output: Duck number
import java.util.Scanner;
while (n != 0) {
count++;
n = n / 10;
}
if (count == 3)
{
n = num;
boolean isDuck = false;
while(n != 0)
{
if(n % 10 == 0)
{
isDuck = true;
break;
}
n = n / 10;
}
if (isDuck) {
System.out.println("Duck Number");
}
else {
System.out.println("Not a Duck Number");
}
}
else {
System.out.println("Invalid");
}
}
}
Output
Question 8
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
void display(int n): To print the square root of each digit of the given number.
Example:
n = 4329
Output – 3.0
1.414213562
1.732050808
2.0
import java.util.Scanner;
System.out.println("Pattern: ");
obj.display();
}
}
Output