0% found this document useful (0 votes)
2K views13 pages

Practice Paper 2 With Answer Key-Ca - Icse 2025 SK

Uploaded by

abhinavk64103
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2K views13 pages

Practice Paper 2 With Answer Key-Ca - Icse 2025 SK

Uploaded by

abhinavk64103
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

COMPUTER APPLICATIONS -CLASS X (Theory)

Maximum Marks: 100


Time allowed: Two hours
Answers to this Paper must be written on the paper provided separately.
You will not be allowed to write during the first 15 minutes.
This time is to be spent in reading the question paper.
The time given at the head of this Paper is the time allowed for writing the answers.

Attempt all questions from Section A and any four questions from Section B.
The intended marks for questions or parts of questions are given in brackets [ ].

SECTION A (40 Marks)


(Attempt all questions from this section.)
For answering Question 1, Correct option has to be
written along with the correct answer
Question 1 [20]
(i) Identify the package used to handle input and output in Java.
(a) java.awt
(b) java.io
(c) java.util
(d) java.lang
Ans. B
ps
(ii) What is the purpose of the `void` keyword in Java?
(a) To define a class.
(b) To define an empty method.
(c) To specify that a method does not return any value.
(d) None of the above.
Ans. C
(iii) Which operator is used to concatenate strings in Java?
(a) `+`
Ki
(b) `&`
(c) `|`
(d) `#`
Ans. A
(iv) What is the size of a `float` data type in Java?
(a) 8 bytes
(b) 2 bytes
(c) 4 bytes
(d) 1 byte
Ans. C
(v) Which method is used to find the length of a string?
(a) `str.size()`
(b) `str.length()`
(c) `str.getLength()`
(d) `str.charAt()`
Ans. B
(vi) What will be the output of the following code?
int x = 5, y = 10;
System.out.println(x * y + x / y);
(a) 51
(b) 52
(c) 50
(d) 49
Ans. C
(vii) What is the access level of a private member in Java?
(a) Within the same package

COMPUTER APPLICATIONS/PRACTICE PAPER 2 / CLASS X/ 2024-25/Page 1


(b) Within the same class
(c) Within the same subclass
(d) Globally accessible
Ans. B
(viii) What is the value of the expression (10 > 5) && (3 < 1)?
(a) true
(b) false
(c) 1
(d) 0
Ans. C
(ix) Which method is used to parse a string to an integer?
(a) `parseInt()`
(b) `toInteger()`
(c) `Integer.parseInt()`
(d) `int.parseInt()`
Ans. C
(x) Name the element of Java represented by the following figure ?
(a) Encapsulation
(b) Abstraction
(c) Inheritance
(d) Polymorphism
Ans. B
(xi) Which keyword is used to define a subclass in Java?

(a) subclass
(b) inherit
ps
(c) extends
(d) implements
Ans. B
(xii) What is the default value of a String variable in Java?
(a) ""
(b) null
Ki
(c) "default"
(d) Undefined
Ans. B
(xiii) What is the output of the following code?
System.out.println("Java" + 2 + 3);

(a) Java23
(b) Java5
(c) Compilation error
(d) 5
Ans. A
(xiv) In Java, what will happen if you divide an integer by zero?
(a) Compilation error
(b) Runtime exception (ArithmeticException)
(c) Returns infinity
(d) Returns NaN
Ans. B
(xv) Which of these is a valid declaration of a 2D array in Java?

(a) int arr[][] = new int[3][3];


(b) int arr = new int[3][3];
(c) int[][] arr = new int[3][3];
(d) Both a and c
Ans. D

COMPUTER APPLICATIONS/PRACTICE PAPER 2 / CLASS X/ 2024-25/Page 2


(xvi) Assertion: Arrays in Java are of fixed size once initialized.
Reason: The size of an array can be dynamically increased or decreased during runtime.

(a) Both Assertion and Reason are true, and the Reason is the correct explanation of the
Assertion.
(b) Both Assertion and Reason are true, but the Reason is not the correct explanation of the
Assertion.
(c) Assertion is true, but the Reason is false.
(d) Both Assertion and Reason are false.

Ans. C

(xvii) Assertion: Strings in Java are immutable.


Reason: The String class in Java uses a mutable char[] array to store its content.

(a) Both Assertion and Reason are true, and the Reason is the correct explanation of the
Assertion.
(b) Both Assertion and Reason are true, but the Reason is not the correct explanation of the
Assertion.
(c) Assertion is true, but the Reason is false.
(d) Both Assertion and Reason are false.

Ans. C
ps
(xviii) What is the output of the following code?

int i = 5;
while (i > 0)
{
System.out.print(i + " ");
i--;
Ki
}

(a) 5 4 3 2 1
(b) 5 4 3 2 1 0
(c) 4 3 2 1
(d) Infinite loop

Ans. A
(xix) What is the output of the following code?
int sum = 0;
for (int i = 1; i <= 3; i++) {
sum += i;
}
System.out.println(sum);
(a) 10
(b) 6
(c) 3
(d) Compilation error
Ans. B
(xx) What is an infinite loop in Java?
(a) A loop that runs only once.
(b) A loop that has a fixed number of iterations.
(c) A loop that never terminates.
(d) None of the above.
Ans. C

COMPUTER APPLICATIONS/PRACTICE PAPER 2 / CLASS X/ 2024-25/Page 3


Question 2 [20]
(i) What do you understand by type conversion? How is implicit conversion different from explicit
conversion?
Ans. The process of converting one predefined type into another is called type conversion. In an implicit conversion,
the result of a mixed mode expression is obtained in the higher most data type of the variables without any
intervention by the user.

(ii) Write two advantages of using functions in a program.


Ans. 1.Methods help to manage the complexity of the program by dividing a bigger complex task into smaller,
easily understood tasks.
2. Methods help with code reusability.

(iii) What is an array? Write a statement to declare an String array of 20 elements.


Ans. An array is a structure to store a number of values of the same data type in contiguous memory locations.
The following statement declares a String array of 20 elements:
String n[] = new String[20];

(iv) What are the values of b and t when the following statements are executed?
int a = 54, b = 22;
boolean b = (a < b)? true : false;
int t = (a < b)? a : b

Ans.
b=false
ps
t=22
(v) Arrange the following primitive data types in descending order of their size:
(i) char (ii) byte (iii) double (iv) int

Ans.
double>int>char>byte
Ki
(vi) Rewrite the following program segment using while instead of for statement.
int s=0, i;
for(i = 1; i <= 5; i++){
s+=i;
System.out.println(s);
}

Ans.
int s = 0, i;
while (i <= 5) {
s+= i;
System.out.println(s);
i++;
}

(vii)
(a) Name the mathematical function which is used to find cosine of an angle given in radians.
(b) Name the string function which finds the position of last occurrence of a character in a string.
Ans.
(a) Math.acos()
(b) lastIndexOf()

(viii) Differentiate between length and length() ?


Ans.

COMPUTER APPLICATIONS/PRACTICE PAPER 2 / CLASS X/ 2024-25/Page 4


length Length()

It is used to find the number of elements in the It is used to find the number of characters
array present in a string.

(ix) Write the output:


char ch ;
int x=115;
do
{
ch=(char)x;
System.out.print(ch + " " );
if(x%10 == 0)
break;
++x;
} while(x<=120);
Ans.
stuvwx
(x) If int y = 5 then find int z = (++y * (y++ + 7));
Ans.
z = (++y * (y++ + 5))
z = (6 * (6 + 7))
z = (6 * 13)
z = 78
ps
SECTION B (60 Marks)
Attempt any four questions from this section.
The answers in this Section should consists of the Programs in Blue J
environment with the Java as the base.
Each program should be written using Variable descriptions/ Mnemonic Codes
Ki
so that the logic of the program is clearly depicted.
Flow-Charts and Algorithms are not required.
Question 3
Define a class called Air_Lounge with the following description:
Instance Variables/Data Members:
String PNR — stores the PNR number of the guest
String name — stores the name of the guest
long mob— stores the mobile number of the guest
Member methods:
1. void input() — To input and store the PNR,name and mobile number
2. void compute() — To accept the number of hours the guest stays in the lounge , calculate and display the
rent at the rate of Rs. 2500 for upto 2 hours and for additional hours Rs. 780 per hour
3. void display() — To display the details .
Write a main method to create an object of the class and call the above member methods.
Ans.
import java.util.*;
class Air_Lounge()
{
int hr,r;
String PNR,name;

COMPUTER APPLICATIONS/PRACTICE PAPER 2 / CLASS X/ 2024-25/Page 5


long mob;

void input() {
Scanner input = new Scanner(System.in);
System.out.print("Enter PNR, name and mobile number: ");
PNR= input.next();
name = input.next();
mob= input.nextLong();
}

void compute()
{
Scanner input = new Scanner(System.in);
System.out.print("Enter number of hours of stay ");
hr= input.next();

if (hr <= 2)
r=2500
else
r= 2500+ (hr - 2) * 780;
}
ps
void display() {
System.out.println("PNR number: " + PNR);
System.out.println("Hours: " + hr);
System.out.println("Rental: " + r);
Ki
}

public static void main(String args[])


{
Air_Loungeob = new Air_Lounge();
ob.input();
ob.compute();
ob.display();
}
}VARIABLE DESCRIPTION TABLE
Variable Type Description
name
PNR String To input the PNR
name String To input the name

mob long To input the mobile number

hr int To input the hours

b int To find the bill

COMPUTER APPLICATIONS/PRACTICE PAPER 2 / CLASS X/ 2024-25/Page 6


Question 4
Write a program to input numbers in a 4 * 4 Double Dimension array.
Display the array. Double every element of the array and display the array.
Ans.

import java.util.*;

class double_dda
{
public static void main(String args[]){
Scanner input = new Scanner(System.in);
int a[][] = new int[4][4];
System.out.println("Enter elements of the array");
for(int i = 0; i < 4; i++)
{
System.out.println("Enter elements of row " + (i+1));
for(int j = 0; j < 4; j++)
{
ps
a[i][j] = input.nextInt();
}
}

System.out.println("Original array :");


Ki
for(int i = 0; i < 4; i++)
{
for(int j = 0; j < 4; j++)
{
System.out.print(a[i][j] + "\t");
}
System.out.println();
}

COMPUTER APPLICATIONS/PRACTICE PAPER 2 / CLASS X/ 2024-25/Page 7


for(int i = 0; i < 4; i++)
{
for(int j = 0; j < 4; j++)
{
a[i][j] = a[i][j] * 2;
}
}

System.out.println("New Array");
for(int i = 0; i < 4; i++)
{
for(int j = 0; j < 4; j++)
{
System.out.print(a[i][j] + "\t");
}
ps
System.out.println();
}
}
}
Ki
VARIABLE DESCRIPTION TABLE
Variable Type Description
name
a[][] Integer Array To input the array
i int To use in the loop

j int To use in the loop

Question 5
Using switch statement, write a menu driven program to:
(i) To find and display all the factors of a number input by the user
Example:
Sample Input : n = 25
Sample Output : 1, 5,25
(ii) To find and display the factorial of a number input by the user (the factorial of a non-negative integer n,
denoted by n!, is the product of all integers less than or equal to n.)
Example:
Sample Input : n = 4
Sample Output : 5! = 1*2*3*4 = 24
For an incorrect choice, an appropriate error message should be displayed.
Ans.
import java.util.*;

COMPUTER APPLICATIONS/PRACTICE PAPER 2 / CLASS X/ 2024-25/Page 8


public class Num_Menu
{
public static void main(String args[])
{
Scanner input = new Scanner(System.in);
System.out.println("1. Factors of number");
System.out.println("2. Factorial of number");
System.out.print("Enter your choice: ");
int choice = input.nextInt();
int num;

switch (choice) {
case 1:
System.out.print("Enter number: ");
num = input.nextInt();
for (int i = 1; i <= num; i++) {
if (num % i == 0)
{
System.out.print(i + " ");
}
}
System.out.println();
ps
break;
case 2:
System.out.print("Enter number: ");
num = input.nextInt();
int f = 1;
Ki
for (int i = 1; i <= num; i++)
f *= i;
System.out.println("Factorial = " + f);
break;

default:
System.out.println("Incorrect Choice");
break;
}
}
}

}VARIABLE DESCRIPTION TABLE


Variable Type Description
name
num int To input the number

COMPUTER APPLICATIONS/PRACTICE PAPER 2 / CLASS X/ 2024-25/Page 9


ch int To input the choice

i int To use in loop

f int To find the factorial

Question 6
Write a program to input the names of 10 students and their marks in two different arrays. Using selection sort
technique create a mark list in which names are arranged in descending order of the marks.
Ans.
import java.util.*;

class ssortm
{
public static void main(String args[])
{
Scanner input=new Scanner(System.in);
int i,j,max=0,t;String x;
String n[]=new String[10];
int m[]=new int[10];
for(i=0;i<10;i++)
{
ps
System.out.println("enter a name");
n[i]=input.next();
System.out.println("enter marks");
m[i]=input.nextInt();
}
for(i=0;i<9;i++)
{
Ki
max=i;
for(j=i+1;j<10;j++)
{
if(m[j]>m[max])
max=j;
}

COMPUTER APPLICATIONS/PRACTICE PAPER 2 / CLASS X/ 2024-25/Page 10


t=m[max];
x=n[max];
m[max]=m[i];
n[max]=n[i];
m[i]=t;
n[i]=x;
}
System.out.println("Sorted Marks List in descending order:");
for(i=0;i<10;i++)
{
System.out.println(n[i]+"\t"+m[i]);
}
}
}VARIABLE DESCRIPTION TABLE
Variable Type Description
name
n[] String Array To input the String array
m[] Integer Array
ps To input the Integer array
i int To use in the loop

j int To use in the loop

Question 8
Ki
Design a class to overload a function area( ) as follows :
(i) void area(double a, double b, double c) with three double arguments, finds the area of a scalene triangle using
the formula :
area=√𝑠(𝑠 − 𝑎)(𝑠 − 𝑏)(𝑠 − 𝑐)
where s=(a+b+c)/2
(ii) void area(int a, int b, int height) with three integer arguments, prints the area of a trapezium using the
formula :
area = 1/2 height(a + b)
(iii) void area(double diagonal1, double diagonal2) with two double arguments, prints the area of a rhombus
using the formula :
area = 1/2 (diagonal1 x diagonal2)

Ans.

COMPUTER APPLICATIONS/PRACTICE PAPER 2 / CLASS X/ 2024-25/Page 11


class AreaOverload
{
void area(double a, double b, double c)
{
double s = (a + b + c) / 2;
double x = s * (s-a) * (s-b) * (s-c);
double result = Math.sqrt(x);
System.out.println(“Area of triangle =”+result);
}

void area (int a, int b, int height)


{
double result = (1.0 / 2.0) * height * (a + b);
System.out.println(“Area of trapezium =”+result);

}
ps
void area (double diagonal1, double diagonal2) {
double result = 1.0 / 2.0 * diagonal1 * diagonal2;
System.out.println(“Area of Rhombus =”+result);

}
Ki
}
} VARIABLE DESCRIPTION TABLE
Variable Type Description
name
i int To use in the loop

j int To use in the loop

Question 9
Write a program to input a sentence and find those words which begin and end with a vowel. Also count the
number of such words.
Sample Input: Ananya and Anushka went to Agra
Sample Output: Ananya
Anushka
Agra
Number of such words =3
Ans. import java.io.*;
class strvowel
{
public static void main(String args[])
{
Scanner input=new Scannerr (System.in);
String s,w="";

COMPUTER APPLICATIONS/PRACTICE PAPER 2 / CLASS X/ 2024-25/Page 12


int i,l,f=0;
char c,c1,c2;
System.out.println("enter a sentence");
s=input.nextLine();
s=s.toUpperCase();
s=s+" ";
l=s.length();
for(i=0;i<l;i++)
{
c=s.charAt(i);
if(c!=' ')
w=w+c;
else
{
c1=w.charAt(0);
c2=w.charAt(w.length()-1);
if((c1=='A'||c1=='E'||c1=='I'||c1=='O'||c1=='U')&&(c2=='A'||c2=='E'||c2=='I'||c2=='O'||c2=='U'))
{
System.out.println(w);
f++;
}
w="";
}
}
ps
System.out.println("Number of times such word occured="+f);
}
}
VARIABLE DESCRIPTION TABLE
Variable Type Description
name
s String To input the sentence
Ki
l int To find the length of the string

i int To use in the loop

c char To extract the character


w String To form the word
c1 char To extract the first character
c2 char To extract the last character
f int To count number of words which begin and end with
vowel

COMPUTER APPLICATIONS/PRACTICE PAPER 2 / CLASS X/ 2024-25/Page 13

You might also like