ComputerApplicationsPP
ComputerApplicationsPP
(Two hours)
Prelim-2, 2024-25
(Practice Paper)
Question 1 [20]
(i)
(iv) State the type of the loop in the given program segment.
for(int i=5;i<=10;i+=2)
System.out.println(i);
(a) Finite loop
(b) Infinite loop
(c) Null loop
(d) Delay loop
(v) Which one of the below is not an example of actual parameter?
(a) max(10,20)
(b) max(n1,20)
(c) max(n1,n2)
(d) void max (int a, int b)
(vi) Which of the following package contains String functions?
(a) java.String
(b) java.util
(c) java.lang
(d) java.io
ICSE 2
(vii) What will be the output?
int x[]={23,6,3,9,6,12};
System.out.println(x[x.length/2]);
(a) 3
(b) 12
(c) 9
(d ) 6
(a ) String
(b) int
(c) char
(d) boolean
(xiii) The error in which the program compiles and executes but shows the incorrect
output.
(a) Syntax error
(xiv) Which of the following access control must be used for the main method to be
invoked by the JVM?
(a) private
(b) public
(c) protected
(d) No access
(xv) The statement (1 > 0) | | (1< 0) evaluates to
(a) 0
(b) 1
(c) true
(d) false
(xvi) Library classes are:______
(a) Set of pre-defined classes
(b) Set of user defined classes
(c) Set of used classes
(d) None of these
ICSE 4
(xvii) Which of the following is NOT true for polymorphism?
(c) Methods should have the same number and the same type of arguments.
(xviii) For which of the following data types, the size of the variable declared will be
fixed?
(a) Primitive
(b) Reference
(c) Composite
(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.
(xx) A student performs a selection sort on the following integer array to arrange it in
ascending order.
{9,20,7,15,8}
After the first iteration the array is
{7,20,9,15,8}
What would be the array after the next comparison?
(a) {7,8,15,20,9}
(b) {7,8,9,15,20}
(c) {7,8,20,15,9}
(d) {7,8,9,20,15}
(ii) Write the output of the following code and how many times will the loop
[2]
execute?
a=5; b=2;
while(b!=0)
{
int r=a%b;
a=b;
b=r;
}
System.out.println(“ a=” +a);
[2]
(iii) State the method that:
(a) converts a String to a primitive float data type.
(b) checks if the entered character is space, tab or newline
[2]
(v) Write Java statements to:
(a) Display the total number of elements in the String[] words array.
(b) Convert the fourth element of the array to uppercase.
ICSE 6
(vii) public static int operate (int a, int b) [2]
{
int c=a++ + ++a-a;
int d=c+ b- - + - -b;
return d;
}
(a) Write a single statement that calls the method operate if it is a member of
class “Mathematics” and values 20 and10 are passed.
(b) What will the method return if a and b are passed as 5 and 10
respectively?
(viii) Write a prototype for a function discount() which accepts two double value and [2]
one integer value and returns double.
(ix) A student is writing a program to display only the alphabets stored in a character [2]
array. While compiling the code, he has made some errors. Debug the code and
write the correct statement
char arr[]={'a','e','6','o','u','%','@'};
int i;
for(i=0;i<arr.length();i++)
{
if(Character.isLetter(arr[i]))
System.out.println(arr);
}
Question 3 [15]
Define a class Anagram to accept two words from the user and check whether they are
anagram of each other or not.
[An anagram of a word is another word that contains the same characters, only the order of
characters is different.]
For example, NOTE and TONE are anagram of each other.
Question 4 [15]
Write a program to accept 10 names (in alphabetical order A-Z) and their corresponding
telephone numbers in two different arrays.
Accept in the name of a person and display telephone no of the corresponding person using
binary search.
Question 5 [15]
Define a class to accept values into a 3x3 array and check if it is a Losho grid or not.
A grid is a Losho grid if the sum of each row and column equals 15.
Print appropriate messages.
Example: 4 9 2
357
816
ICSE 8
Question 6 [15]
Define a class PhoneBill with the following descriptions:
Data members:
customerName : to store the name of the customer
phoneNo : to store the mobile number of the customer
no_of_unit : to store number of calls made
rent : to store monthly rent
amount : to store amount to be paid.
Member Methods:
PhoneBill() : to initialize with default value to each data member.
accept() : to accept customer name, phone number, number of units and rent.
display() : to display the values of all the data members on the screen
main() : Create an object and invoke the above methods.
Question 7 [15]
Define a class to overload the method display() as follows
void display() :to print the following pattern using nested loop
12121
12121
12121
12121
void display(int n) -To display the sum of the series given below:
𝟏 𝟐 𝟑 𝟒
− + − + ⋯ . . 𝑛 𝑡𝑒𝑟𝑚𝑠
𝟐 𝟑 𝟒 𝟓
Write a main method to create an object and invoke the above methods.
************
ICSE 10