Scottish High International School
Pre-Board Optional Examination (2023-24)
Class X ICSE
Subject: Computer Applications
Max. Marks: 100
Time allotted: Two hours
Answer to this paper must be written on the paper provided separately.
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. [20 x 1 =20]
Choose the correct answer and write the correct option.
(Do not copy the question. Write the correct answers only.)
(i). Which of the Object-Oriented Programming principles explain the following illustration?
The variables and methods are put together in the class
(a) Encapsulation
(b) Abstraction
(c) Inheritance
(d) Polymorphism
(ii). Read the below code statement of class named ‘Test’ and mention the right way to call the method
abc in main method?
static void abc()
{
int x=3; int y=x+10;
}
Test ob = new Test();
(a) ob.Test()
(b) ob.abc()
(c) Test()
(d) abc()
(iii). Which of the following is binary relational operator?
(a) ==
(b) !
(c) +
(d) &&
(iv). int x=’a’; what is the value of x?
(a) a
(b) error
(c) 65
(d) 97
(v). A wrapper class converts
(a) int to float
(b) float to int
(c) primitive datatype to object
(d) int to String
(vi). Non static functions can access
(a) static data members
(b) non static data members
(c) a only
(d) both a and b
(vii). The process of calling a method in such a way that the change in the formal arguments reflects on the
actual parameter is known as:
(a) call by value
(b) call by reference
(c) call by method
(d) None of the above
(viii). Read the following text, and choose the correct answer: Repetitive execution of a set of statements is
termed as looping. The two types of looping statements are entry controlled and exit controlled loops.
Both while and for are termed as entry-controlled loops. A for loop is used when the number of
iterations is known. A while is used when the set of statements are executed as long as the condition
is true, it is executed when the number of iterations are not known.
Which one of the following is infinite loop?
(a) for(int k = 1; k<=100;k++)
(b) int k=1; while(k>0) {k++;}
(c) for(int k=1;k<=100000;k++ ){}
(d) int k=100; while(k>0) {k-=2;}
(ix). The output of Math.pow(25,1/2) + Math.sqrt(Math.min(4,9)); is:
(a) 3
(b) 3.0
(c) 7
(d) 7.0
(x). Predict the Output for the following snippet:
int i;
for (i=1; i<=3; i++)
System.out.print(i++);
(a) 4
(b) 123
(c) 13
(d) 5
(xi). What will be the output of the following code segment:
int y=5, x;
for (x=10; x<= 15; x++)
y--;
System.out.print((x+y) + " ,");
(a) 20 ,
(b) 15 ,
(c) 16 ,
(d) 15, 14, 13, 12, 11, 10
(xii). Find the output of the following code
int m= 49;
switch(m+ 1)
{
default:
System.out.println( Math.pow(5.2));
case 49:
System.ont.println(Math.sqrt(m));
break;
}
( a ) 25.0
( b ) 25.0
7.0
( c ) error, expression m+1 cannot he written in switch.
( d ) error, default should be always at the end.
(xiii). What will be the output of the following program snippet?
str1 = "AMAN";
str2 = "AMIT";
System.out.println(str1.compareTo(str2));
(a) 8
(b) 0
(c) -8
(d) 2
(xiv). Assertive (A): A class is known as object factory.
Reason (R): Objects are created from class which contains common attributes & behaviour
(a) Both Assertion (A) and Reason (R) are true and Reason(R) is correct explanation of
Assertion (A).
(b) Both Assertion (A) and Reason (R) are true and Reason(R) is not correct.
(c) Assertion (A) is true and Reason (R) is false.
(d) Assertion (A) is false and Reason (R) is true.
(xv). Assertion (A): Java is platform-independent due to its "Write Once, Run Anywhere" (WORA)
capability.
Reason (R): Java code is compiled into bytecode, which can run on any platform with a
compatible Java Virtual Machine (JVM).
(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
(xvi). Which of the following statements is true regarding encapsulation?
(a) Encapsulation is primarily concerned with code execution speed
(b) Encapsulation allows objects to hide their implementation details
(c) Encapsulation is only applicable to primitive data types
(d) Encapsulation is achieved using the finalize method
(xvii). Assertive (A): Increment and decrement operators are binary operators
Reason (R): Increment and decrement operators require only one operand
(a) Both Assertion (A) and Reason (R) are true and Reason(R) is correct explanation of
Assertion (A).
(b) Both Assertion (A) and Reason (R) are true and Reason(R) is not correct.
(c) Assertion (A) is true and Reason (R) is false.
(d) Assertion (A) is false and Reason (R) is true.
(xviii). What will be the output for:
public static void main(String[] args)
String str = "Information Technology";
int p;
p = str.indexOf('n');
System.out.println(p);
(a) 0
(b) 1
(c) 10
(d) 17
(xix). What will be the output for:
public static void main(String[] args)
char x=’A’;
int m;
m=(x==’a’)?’A’:’a’;
System.out.println(“m = ” + m);
}
(a) m = 65
(b) m=a
(c) m = 97
(d) m=A
(xx). Math.random() is an example for
(a) pure function
(b) impure function
(c) user defined function
(d) Character function
Question 2
(i). Write the Java expression for the following equation: [2]
(ii).int ar[]={2,5,8,9,1,6,4,9,3,5}; [2]
(a) State the start and end indices of ar[]
(b) State the element stored at 3rd and 7th index
(c) Write a java statement to find and print the middle index of the element present.
(d) Write a java statement to state whether sum of the elements from 0 to 4 index are more than sum
of elements from 5 to 9 index or not.
(iii). The following code segment should print x is divisible by 2 or x is less than 20. [2]
However, the code has errors. Fix the code so that it compiles and runs correctly.
int x;
if(x/2==0 && x>=20)
System.out.println(“x is divisible by 2 or x is less than 20”);
else
System.out.println(“x is not divisible”);
(iv). Predict the output of the following code snippet: [2]
String s=”PreBoardExamination2024”;
(a) s.substring(13,19).toUpperCase()+”AL”;
(b) s.lastIndexOf(‘e’);
(c) s.charAt(0)+s.charAt(3)+s.charAt(8).concat(“2024”);
(d) s.substring(19);
(v). Explain function overloading with example [2]
(vi). Write java statements for the following [2]
(a) Create an array to hold 15 double values.
(b) Assign the value 10.5 to the last element in the array.
(vii). Name the data type and the value returned by the following functions. [2]
(a) Math.round(8.5);
(b) String s= “colour”; System.out.println(s.indexOf(‘o’)+s.lastIndexOf(‘o’));
(viii). Write the output of the following String methods: [2]
(a) "ARTIFICIAL ".indexOf('I' )
(b) “DOG and PUPPY”. substring( 6 )
(c) “ BEAUTIFUL DAY “. trim().length()
(d) “School Day”.endsWith(“DAY”)
(ix). Predict the output of the following code snippet: [2]
class GFG {
public static void main(String[] args)
{
String str = "100";
float val = Float.parseFloat(str);
System.out.println("Value = " + val);
}
}
(x). Evaluate the expression when the value of x=10, y=5; [2]
float z=y/x + ++x + ++y;
SECTION B
(Answer any four questions from this Section.)
The answers in this section should consist of the programs in either BlueJ environment or any
program environment with java as the base.
Each program should be written using variable description / mnemonic codes so that the logic of
the program is clearly depicted.
Flowcharts and algorithms are not required.
Question 3 [15]
Create a class name Charity Hospital which will calculate the gift amount for the donors based on
the donation amount as given in the following table.
Donation amount Gift amount
<=50,000 10% of the Donation amount
>50,000 and <=1,00,000 2000+ 15% of the donation amount greater than Rs.50,000
>1,00,000 Rs.5000+ 20% of the donation amount greater then Rs.1,00,000
There can be 2 types of donors A-annual donors and O-one time donors.
If they are annual donors then an additional 5% is added to the gift amount and an additional 2% is
added to the gift amount if they are one time donors.
Write a program to calculate the Gift amount and print it in the following format.
Class name : CharityHospital
Data members : Name of the donor(n),
type of donors(t),
Donation amount(da)
mobile number(mob),
Gift amount(gf)
CharityHospital(): Constructor to initialize the data members
void Accept() : To accept name of the donor, type (t),donation amount and the mobile number
void cal_Amount(): To calculate the Gift amount based the table and store it in the gift amount(gf)
void Add_amount(): To add additional gift amount depending on the type of donors void Display():
To print all the details in the following format:
Name : ------ Mobile no.: -------- Type of donor : -----
Donation Amount : ----------- Gift Amount: ----------
Write a main method to create an object of the class and call the above member methods.
Question 4 [15]
Write a program to store the names of any 10 elements of the Periodic table in the string type array
along with their atomic number in an integer array. Sort the element in Ascending order of their
atomic number using any standard sorting technique and display the names of elements along with
their atomic number after sorting.
For example:
Input Array1: Ca Fe Li Na(elements of the periodic table)
Array2: 20 26 3 11(corresponding atomic number)
Output: Sorted elements with respect to their atomic number
Array1: Li Na Ca Fe
Array2: 3 11 20 26
Question 5 [15]
Define a class to overload a function compare() as follows:
a. void compare(int,int) - to compare two integer values and print the greater of the two integers.
b. void compare(char,char) - to compare the numeric values of two characters and print the character
with higher numeric value.
c. void compare(String, String) - to compare the length of the two strings and print the longer of the
two.
Question 6 [15]
Design a class to overload a function Pattern() as follows
void Pattern(int n): to print the following pattern if n=5
# 14 # 12 #
# 10 # 8
#6#
#4
#
void Pattern(String s): To print the characters of the string s which are not repeating
Eg: success characters to be printed u,e
void Pattern(): to print the following pattern
APPLE
APPL
APP
AP
A
Write a main method, create object and call the above functions
Question 7 [15]
Write a program to input 10 numbers into a float type array and arrange the numbers in
descending order using Bubble Sorting technique.
Question 8 [15]
Define a class to accept a string and convert it into lowercase and check whether the string is a
palindrome or not. A palindrome is a word which reads the same backward as forward.
Example: MADAM, racecar etc.