CLASS: X PRE-FINAL EXAMINATION 2025 -26 Marks: 100
Subject: COMPUTER APPLICATIONS Time: 2 Hours
Answer 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 answer.
This paper is divided into two Sections.
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
[Attempt all questions from this Section]
Question 1 Multiple Choice Questions: [20 x 1 = 20]
1) Choose the odd one out from the following:
(a) ! (b) || (c) == (d) &&
2) Corresponding wrapper class of float data type is .......
(a) FLOAT (b) float (c) Float (d) Floating
3) Method overloading is an OOP feature, that is .......
(a) Inheritance (b) Encapsulation (c) Abstraction (d) Polymorphism
4) Which of the following returns a String?
(a) length() (b) charAt(int) (c) replace(char, char) (d) indexOf(String)
5) The output of Math.round(6.6) + Math.ceil(3.4) is:
(a) 9.0 (b) 10.0 (c) 11.0 (d) 12.0
6) The expression which uses > = operator is known as:
(a) relational (b) logical (c) arithmetic (d) assignment
7) The Scanner class method used to accept words with space:
(a) next() (b) nextLine() (c) Next() (d) nextString()
8) Which of the following is the CORRECT statement to invoke the method with the prototype
int display(int a, char ch)?
(a) int m = display(‘A’, 45); (b) int m = display( );
(c) int m = display(A,45); (d) int m = display(45, ‘A’);
9) Java statement to access the 5th element of an array is:
(a) X[0] (b) X[3] (c) X[4] (d) X[5]
10) What is the type of error, if any, when two methods have the same method signature?
(a) Runtime error (b) Logical error (c) Syntax error (d) No error
11) Variable that is declared within the body of a method is termed as:
(a) instance variable (b) local variable (c) classic variable (d) class variable
12) Choose the odd one out:
(a) double (b) int (c) char (d) String
13) The expression which uses > = operator is known as:
(a) relational (b) logical (c) arithmetic (d) assignment
14) To execute a loop 10 times, which of the following is correct?
(a) for (int i = 11; i <= 30 ;i+=2) (b) for (int i = 11 ;i<=30;i+=3)
(c) for (int i = 11; i < 20 ;i++) (d) for (int i=11;i<=21;i++)
15) Assertion (A): Assertion: An array can store elements of different data types
Reason (R): An array is a user-defined data type with multiple values of the same data
type but a different memory index.
(a) Assertion is true, Reason is false. (b) Both Assertion and Reason are false.
(c) Both Assertion and Reason are true. (d) Assertion is false, Reason is true.
16) Assertion (A): Constructors are special methods used to initialize objects.
Reason (R): Constructors can have any return type.
(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
17) int x=(int) 32.8; is an example of _____________ type casting.
(a) implicit (b) automatic (c) explicit (d) coercion
18) Which of the following is a valid method prototype?
(a) public int perform (int a;int b) (b) public perform (int a, int b)
(c)public int perform (int a, int b) (d)public perform int (int a,int b)
19) A method is called automatically when we create an object, it doesn’t need to be called.
(a) void method (b) non-void method (c) Constructor (d) static
20) Assertion (A): The indexOf() method returns the index of the last occurrence of a character in a string.
Reason (R): The indexOf() method returns -1 if the character is not found.
(a) Assertion is true, Reason is false. (b) Both Assertion and Reason are false.
(c) Both Assertion and Reason are true. (d) Assertion is false, Reason is true.
Question 2.
1) Which data structure is represented in the above picture? [2]
(i) A two-dimensional array with 2 rows and seven columns.
(ii) A one-dimensional array with 14 elements.
(a) Both (i) and (ii) (b) Only (i) (c) Only (ii) (d) None of the (i) and (ii)
2) Name the method of search depicted in the above picture. [2]
(a) Binary Search (b) Selection Sort (c) Bubble Sort (d) Linear Search
3) Name the following: [2]
(a) Method with the same name as of the class and is invoked every time an object is created. Constructor
(b) A Character method that checks whether a character is an alphabet or a number. Character.isLetterOrDigit()
4) A manager wants to check the number of employees with names ending with KUMAR, and fill in the blanks in the given program segment with appropriate Java statements: [2]
void count(String S[])
{
int i, l=_________, c=0;
for(i=0;i<l;i++)
{
if(________________)
c++;
}
System.out.println(c);
}
void count(String S[])
{ int i, l = S.length, c = 0; // ✅ length of the array
for(i = 0; i < l; i++)
{
if(S[i].endsWith("KUMAR")) // ✅ check if name ends with "KUMAR"
c++;
}
System.out.println(c);
}
5) Convert the following for loop segment to an exit-controlled loop. [2]
for(k=10;k>= -1;k- -)
System. out. println(k*2);
System. out. println(k*4);
k = 10;
do {
System.out.println(k * 2);
k--;
} while(k >= -1);
System.out.println(k * 4);
Question 3.
1)
State the output: [2]
int m = 100;
int n = 110;
while(++m < --n)
System.out.println(++m);
Output:
102
104
106
2) The output of the statement of “TIGER”. indexOf(‘G’) is: [2]
(a) 3 (b) 2 (c) -1 (d) 0
3) The output of the java statement “SOLDIER”. compareTo(“SOLUTE”); is [2]
(a) -4 (b) -17 (c) 17 (d) 0
4) The output of the following statement is: [2]
void encode()
{
String s = "HEllo";
char ch;
for (i = 0; i < s.length(); i++) {
ch = s.charAt(i);
if ("AEIOUaeiou".indexOf(ch) >= 0)
System.out.println("@");
else
System.out.println(ch);
}
}
5) Write the java expressions: [2]
F=Math.sqrt((1/L*C) – ((R*R)/(4*C*C))
Section – B (60 Marks)
Each program should be written using Variable descriptions/Mnemonic Codes so that the logic of the program is clearly depicted.
Flow-Charts and Algorithms are not required
(Attempt any four questions from this Section.)
Question 4. [15]
Fashion Courier Service charges for the parcels of its customers as per the following specifications.
Class name: FashionCourier
Member/Instance variables:
String name: to store the name of the customer
int wt: to store the weight of the parcel in kg double charge: to store the charge of the parcel Member methods:
Weight Charge
Less than 5 kgs Rs. 50 per kg
Above 5 kgs and less than 10 kgs Rs. 150 per kg
Above 10 kgs and less than 20 kgs Rs. 200 per kg
Above 20 kgs Rs. 350 per kg
FashionCourier() : default constructor to initialise the member variables with their respective default initial values. void accept(): to accept the name of the customer and weight of the parcel.
void compute(): to calculate the charge as per the following criteria.
A surcharge of 5% is charged on the bill as well.
void display (): to display the name of the customer, weight of the parcel and total bill inclusive of surcharge in a tabular format in the following format:
Name Weight Bill amount
***** ***** ********
Define a main method to create an object of the class and call the member methods.
import java.util.Scanner;
class FashionCourier {
String name;
int wt;
double charge;
FashionCourier() {
name = "";
wt = 0;
charge = 0.0;
}
void accept() {
Scanner sc = new Scanner(System.in);
System.out.print("Enter customer name: ");
name = sc.nextLine();
System.out.print("Enter parcel weight (in kg): ");
wt = sc.nextInt();
}
void compute() {
if (wt < 5) {
charge = wt * 50;
} else if (wt >= 5 && wt < 10) {
charge = wt * 150;
} else if (wt >= 10 && wt < 20) {
charge = wt * 200;
} else {
charge = wt * 350;
}
charge = charge + (0.05 * charge);
}
void display() {
System.out.println("Name\t\tWeight\t\tBill amount");
System.out.println(name + "\t\t" + wt + " kg\t\tRs. " + charge);
}
public static void main()
{
FashionCourier obj = new FashionCourier();
obj.accept();
obj.compute();
obj.display();
}
}
Question 5. [15]
(a) Write a program to accept a number and calculate the norm of the number.
Norm of a number is the square root of the sum of the squares of all digits of the number.
Example: The norm of 68 is 10
6×6 + 8x8 = 36+64= 100
Square root of 100 is 10.
import java.util.Scanner;
class Norm
{
public static void main()
{
Int n,t,r,s=0,t;
Scanner sc = new Scanner(System.in);
System.out.print("Enter a number: ");
n = sc.nextInt();
t = n;
s = 0;
while (t != 0)
{
r = t % 10;
s+= r * r;
t /= 10;
}
double norm = Math.sqrt(s);
System.out.println("Norm of " + n + " = " + norm);
}
}
(b) Define a class to accept a number. Check if the sum of the largest digit and the smallest digit is an even number or an odd number. Print appropriate messages.
Sample Input:
6425
3748
Largest digit:
6
8
Smallest digit:
2
3
Sample Output:
Sum is even
Sum is odd
import java.util.Scanner;
class DigitSumCheck {
int n, l, s;
void accept()
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter a number: ");
n = sc.nextInt();
}
void compute()
{
int t = n;
l = 0;
s = 9;
while (t > 0) {
int r = t % 10;
if (r > l)
l = r;
if (r < s)
s = r;
t /= 10;
}
}
void display() {
int sum = largest + smallest;
System.out.println("Largest digit: " + l);
System.out.println("Smallest digit: " + s);
System.out.println("Sum = " + s);
if (s % 2 == 0) {
System.out.println("Sum is even");
} else {
System.out.println("Sum is odd");
}
}
public static void main()
{
DigitSumCheck obj = new DigitSumCheck();
obj.accept();
obj.compute();
obj.display();
}
}
Question 6. [15]
Define a class to Overload the method result() as follows:
a. result( )- Print the following series. A, C, E, G………. n terms.
b. result(int a, int n)- To print the sum of the given series:
@
@ $
@ $ @
@ $ @ $
c. result(char ch, char ch )- To print the following pattern using the character $ and @
import java.util.Scanner;
class OverloadResult
{
// (a) result() - Print series A, C, E, G... n terms
void result() {
Scanner sc = new Scanner(System.in);
System.out.print("Enter number of terms: ");
int n = sc.nextInt();
char ch = 'A';
System.out.println("Series:");
for (int i = 1; i <= n; i++) {
System.out.print(ch + " ");
ch += 2; // skip one character to get A, C, E, G...
}
System.out.println();
}
// (b) result(int a, int n) - Print sum of series a/1 + a/2 + ... n terms
void result(int a, int n) {
double sum = 0.0;
for (int i = 1; i <= n; i++) {
sum += (double)a / i;
}
System.out.println("Sum of series = " + sum);
}
// (c) result(char ch1, char ch2) - Print pattern using $ and @
void result(char ch1, char ch2) {
int rows = 4; // fixed as per example
for (int i = 1; i <= rows; i++) {
for (int j = 1; j <= i; j++) {
if (j % 2 == 1) {
System.out.print(ch1 + "\t");
} else {
System.out.print(ch2 + "\t");
}
}
System.out.println();
}
}
public static void main()
{
OverloadResult obj = new OverloadResult();
obj.result(); // prints series A, C, E, G...
obj.result(5, 4); // example: sum of series with a=5, n=4
obj.result('@', '$'); // prints pattern with @ and $
}
}
Question 7. [15]
(a) Define a class to accept a String and Print if it is a Super string or not. A String is Super if the number of uppercase letters is equal to the number of lower-case letters. [Use Character & String methods only]
Example : “COmmITmeNt”
Number of Uppercase letters – 5
Number of Lowercase letters – 5
String is a Super String
import java.util.Scanner;
class SuperString
{
String str;
int u;
int l;
void accept() {
Scanner sc = new Scanner(System.in);
System.out.print("Enter a string: ");
str = sc.nextLine();
}
void compute() {
u = 0;
l = 0;
for (int i = 0; i < str.length(); i++)
{
char ch = str.charAt(i);
if (Character.isUpperCase(ch))
{
u++;
}
else if (Character.isLowerCase(ch))
{
l++;
}
}
}
void display() {
System.out.println("Number of Uppercase letters = " + u);
System.out.println("Number of Lowercase letters = " + l);
if (u == l)
{
System.out.println("String is a Super String");
}
else
{
System.out.println("String is NOT a Super String");
}
}
public static void main() {
SuperString obj = new SuperString();
obj.accept();
obj.compute();
obj.display();
}
}
(b) Write a Java Program to input a string and check it is a palindrome string, a special word or neither.
A string is called palindrome when the string is read from left to right or from right to left it is the same string. A string is called special word if it starts and ends with the same character.
Sample Input: madam
Sample Output: Palindrome string
Sample Input: comic
Sample Output: Special word
import java.util.Scanner;
class StringCheck
{
String str;
void accept()
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter a string: ");
str = sc.nextLine();
}
boolean isPalindrome() {
String rev = "";
for (int i = str.length() - 1; i >= 0; i--)
{
rev += str.charAt(i);
}
return str.equalsIgnoreCase(rev);
}
// Method to check special word
boolean isSpecialWord() {
if (str.length() > 0) {
return str.charAt(0) == str.charAt(str.length() - 1);
}
return false;
}
void display()
{
if (isPalindrome())
{
System.out.println("Palindrome string");
}
else if (isSpecialWord())
{
System.out.println("Special word");
} else {
System.out.println("Neither Palindrome nor Special word");
}
}
public static void main() {
StringCheck obj = new StringCheck();
obj.accept();
obj.display();
}
}
Question 8. [15]
Write a program in Java to store the numbers in a m x n matrix in Double Dimensional Array and print the Sum of Odd elements and Sum of Even elements
import java.util.Scanner;
class MatrixSum
{
public static void main()
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter number of rows (m): ");
int m = sc.nextInt();
System.out.print("Enter number of columns (n): ");
int n = sc.nextInt();
int[][] M = new int[m][n];
System.out.println("Enter the elements of the matrix:");
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
M[i][j] = sc.nextInt();
}
}
int sumEven = 0, sumOdd = 0;
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
if (M[i][j] % 2 == 0) {
sumEven += M[i][j];
} else {
sumOdd += M[i][j];
}
}
}
System.out.println("Sum of Even elements = " + sumEven);
System.out.println("Sum of Odd elements = " + sumOdd);
}
}
Question 9. [15]
Write a program in Java to store the numbers in a 4 x 4 matrix in Double Dimensional Array and print the sort the elements using Bubble Sort technique in another DDA.
import java.util.Scanner;
class MatrixBubbleSort {
public static void main() {
Scanner sc = new Scanner(System.in);
int m = 4, n = 4;
int[][] M = new int[m][n];
// Input matrix
System.out.println("Enter elements of 4x4 matrix:");
for (int i = 0; i < m; i++)
{
for (int j = 0; j < n; j++)
{
M[i][j] = sc.nextInt();
}
}
int[] A = new int[m * n];
int x = 0,t;
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
A[x++] = M[i][j];
}
}
for (int i = 0; i < A.length - 1; i++)
{
for (int j = 0; j < A.length - i - 1; j++)
{
if (A[j] > A[j + 1])
{
t = A[j];
A[j] = A[j + 1];
A[j + 1] = temp;
}
}
}
int[][] sortedMatrix = new int[m][n];
index = 0;
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
sortedMatrix[i][j] = A[index++];
}
}
System.out.println("\nOriginal Matrix:");
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
System.out.print(M[i][j] + "\t");
}
System.out.println();
}
System.out.println("\nSorted Matrix:");
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
System.out.print(sortedMatrix[i][j] + "\t");
}
System.out.println();
}
}
}