COMP PP
COMP PP
(Two hours)
Practice Paper-I, 2024-2025
GRADE: X Max. Marks: 100
Question 1 [20]
(i)
(iv) Method prototype for the method calculation which accepts two character arguments
and returns true/false.
a. void calculate(char a, char b) b. boolean calculate(char a, char b)
c. Boolean calculate(char a,b) d. int calculate(char a, char b)
(vi) A single dimensional array has 20 elements, which of the following is a correct
statement to initialize the last element to 50.
a. A[21]=50 b. A[18]=50
c. A[19]=50 d. A[20]=50
(viii) Assertion(A): Integer class can be used in the program without calling a package.
Reason(R): It belongs to the default package java.lang.
a. Both Assertion(A) and Reason(R ) are true and Reason(R ) is a correct
explanation of Assertion(A).
b. Both Assertion(A) and Reason(R ) are true and Reason(R ) is not a correct
explanation of Assertion(A).
c. Assertion(A) is true and Reason(R ) is false.
d. Assertion(A) is false and Reason(R ) is true
ICSE 2
(x) Which of the following is the CORRECT statement to invoke a method with the
prototype int display(int a, char b)?
a. int n= display(‘P’,20)
b. int n=display();
c. int n= display(20, ‘P’);
d. int n= display(20, P);
(xi) Conversion of a wrapper class object to its primitive type is known as:
a. unboxing b. autoboxing
c. type casting d. parsing
(xii) A girl wanted to calculate the sum of two numbers stored as a and b multiplied by 7.
Select the appropriate Java expression.
a. a+b*7
b. 7*a+b
c. (a+b)*7
d. a+7*b
(xiii)
How many bytes are occupied by the above one dimensional array?
a. 5 bytes b. 10 bytes
c. 20 bytes d. 15 bytes
(xiv) The Vivanta hotel gives the amount to be paid by the customer as an integer, which of
the following method rounds off the bill in decimals to an integer?
a. Math.round() b. Math.Round()
c. Math.roundoff() d. Math.RoundOff()
(xv) A package is a :
a. Collection of data.
b. Collection of functions.
c. Collection of classes.
d. A nested class.
(xvi) Read the following text and choose the correct answer
The data members or member methods which are specified as private are used only
within the scope of a class. These members cannot be accessed outside the class
visibility. Next clue
Which of the following statement is most appropriate for the private members?
a. They are visible outside the class in which they are defined.
b. They can be used in the sub class.
c. They are only visible in the class in which they are declared.
d. They are globally visible.
Question 2
(i) How many times the given loop is executed? Give the output of the same. [2]
for(k=10;k<=20;k+=4)
{
System.out.println(k);
if(k%3==0)
continue;
}
ICSE 4
(iii) Consider the given program and answer the questions given below: [2]
class temp
{
int a;
temp()
{
a=10;
}
temp(int z)
{
a=z;
}
void print()
{
System.out.println(a);
}
void main()
{
temp t = new temp();
temp x = new temp(30);
t.print();
x.print(); } }
a. What concept of OOPs is depicted in the above program with two constructors?
b. What is the output of the method main()?
(iv) What is the data type that the following functions return? [2]
a. isWhiteSpace(char ch)
b. Math.random()
3
(v) Write the Java expression for √𝑥 + √𝑦 [2]
(vi) What is the value of m after evaluating the following expression: [2]
m += 10% ++n +n++ /4 , when m=12 and n=3.
(vii) Consider the following method which calculates and returns the Norm of a matrix. [2]
Norm is square root of sum of squares of all elements.
Fill in the blanks (a) and (b) with appropriate java statements:
double norm()
{
int x[][]={{1,5,6},{4,2,9},{6,1,3}};
int r, c, sum=0;
(ix) Consider the following program segment and answer the questions given: [2]
for(int k=1;k<=5;k++)
System.out.println(k);
System.out.println(k);
a. Will the program segment get executed successfully?
b. If not, state the type of error. How do you correct the program if it has any error?
ICSE 6
SECTION II (60 Marks)
Attempt any four questions from this section.
Question 3 [15]
Design a class with the following specifications:
Member methods
void accept(): Accept the name and price of the item using the Scanner class.
void calculate(): To calculate the net amount to be paid by a customer, based on
following criteria:
Price Discount
1000- 25000 5.0%
25001-57000 7.5%
57001-100000 10.0%
More than 100000 15.0%
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.
Question 4 [15]
Write a program in Java to create a 3 x 3 square matrix and store numbers in it. The
programmer wants to print the given Matrix and check whether the matrix is a symmetric
matrix or not. A square matrix is said to be symmetric if the elements of the ith row and jth
column is equal to the elements of the jth row and ith column.
For Example :
A Symmetric matrix:
1 2 3
2 4 5
3 5 6
Question 6 [15]
Write a program in Java to store 10 words in a Single Dimensional Array. Display only those
words which are Palindrome.
Sample Input: MADAM, TEACHER, SCHOOL, ABBA, .........
Sample Output: MADAM ABBA .......... ..........
Question 7 [15]
Define a class to accept a four-digit number and check if it is a USHWA number or not.
The number is said to be USHWA if:
Sum of all digits= 2× (sum of first and last digit)
Example 1: n =1234
Sum of first and last digit = 1+4=5
Sum of all digits =1+2+3+4=10
Sample output: It is a USHWA number
Example 2: If the input value is 354, then an error message should be given.
Question 8 [15]
Define a class to overload the function print as follows:
void print(): to print the following format
1 1 1 1
2 2 2 2
3 3 3 3
4 4 4 4
5 5 5 5
void print(int n): To check whether the number is a lead number. A lead number
is the one whose sum of even digits are equal to sum of odd
digits. e.g. 3669
odd digits sum = 3 + 9 = 12
even digits sum = 6 + 6 = 12
3669 is a lead number
void print(char ch, int a): If ch=s or S print the square of the number and if ch=c or C
print the cube of the number.
ICSE 8