100% found this document useful (1 vote)
70 views10 pages

Preboard Computer Science. 2024

Uploaded by

sanidhyapratap03
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
100% found this document useful (1 vote)
70 views10 pages

Preboard Computer Science. 2024

Uploaded by

sanidhyapratap03
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/ 10

SALT LAKE SCHOOL

REHEARSAL EXAMINATION 2024


CLASS X
COMPUTER APPLICATIONS
Maximum Marks: 100 Reading time:15mins 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.

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 bracketsl J

SECTION A
(Attemptall questions from this Section.)

Question 1

Choose the correct answers to the questions from the given options. (Do not copy the question, write the

correct answers only.) (20]

Vehicle
X
(yele
Car Truck

Name the feature of java depicted in the above picture.

(a) Encapsulation
(b) Inheritance

(c) Abstraction

(d) Polymorphism

(ii )ldentify the type of operator &&:

(a) ternary
(b) unary
(c) logical
(d)relational
used to accept words with space:
(ii) The Scanner class method

(a) next()

(b) nextLine()

(c) Next()
(d) nextString( )

situation in switch case statement?


to fall through
of which statement leads
(iv) The absence

(a) continue
(b) break
(c) return

(d) System.exit(0)

bytes occupied by a character array of 10 elements.


(v) The number of

(a) 20 bytes
(b) 60 bytes
(c) 40bytes
(d) 120 bytes

the given program segment:


(vi) State the type of loop in

for (int i=5; i !=0; i-=2)

System.out.println();

(a) finite

(b) infinite

(c) null

(d)fixed

a char:
integer argumentand returns
check() which takes an
(vii) A method prototype name
(a) char check()

(b) void check (int x)

(c) check (int x)

(d) char check (int x)

The output of Math.round(6.3) + Math.ceil(9.1) is:


(vii)
(a) 15.0

(b) 16.0

(c) 17.0

(d) 16

Page 2 of 10
iN) Predict the output of the following code snippet: String P="20", Q="22";
int a = Integer.parselnt(P);

int b= Integer. valueOf(Q);


System.out.println(at "+b);

(a) 20
(b) 20 22
(c) 2220
(d) 22

()The numberof bits occupied by the value 'a' are:


(a) bit
1
(b) 2 bits

(c) 4 bits

(d) bits
16
(xi)The output of the function "COMPOSITION".substring(3, 6):

(a) POSI

(b) POS

(c) MPO

(d) MPOS

(xii) int x= (int) 47.9; is an example of typecasting

(a) implicit

(b) automatic

(c) explicit

(d) None ofthe above

that contains wrapper classes:


(xii) Name the package

(a) java.lang

(b) java.util

(c) java .io

(d) java.awt

Page 3 of 10
i as:
is termed
of variables
value
method which does not modifythe
(xiv) A

(a) impure method

(b)pure method

(c) primitive method

(d) user defined method

thefollowing is a valid double constant:


(xv) Which of

1. 4

2 4.0

3 4.3f

4 "four

(a) Only I.

(b) 1. and
3.
(c) 2. and 4.

(d) 1. and 2.

when two strings are equal


(xvi) The method equals) returns

true
(a)

(b)

(c)

(d) false

Read the following text, and choose the correct answer:

Assertion (A) - We should not give the same name to two identifiers even if the

language allows it.

Reason (R-Giving proper identifier names makes a program self-documenting

a)Both A and R are true and R is the correct explanation of A

b) Both A and R are true but R is not the correct explanation ofA

c) A is true but R is false

d)A is false but R is true

Page 4 of 10
): In Java, statemlens
Assertion(A
xvii)
are treated as the same.

Java is a case sensitive language.


Reason(R): of
(R)is a correct explanation
and Reason
Assertion(A)and
Reason(R)are true
a) Both

Assertion (A) of

(R) is not a correct explanation


(R)are true and Reason
(A)and Reason
b) Both Assertion
Assertion (A)

true and Reason


(R)is false

c) Assertion (A) is

false and Reason(R)is true


d) Assertion(A) is

if x=3, y=5, and z=10:


following Java expression,
(xix) Evaluate the

+tz+y - y+z+ x++

a)24

b)23

c)20

d)25
to perform
be used in our program
are the built-in modules that can are used for specific
functions.
(xx) Functions that
are some mathematical functions
There
a specific operation. square root of a positive
function to return return
we can use Math.sqrt() and Math.ceil() to
For example, number in a range of numbers
random
number, Math.random() to return

number.
the next higher integer

answer the following question:


Based on the above discussion,

is executed?
be displayed, if the following statement
What will

(Math.sqrt(-25);
System.out.printIn

Infinite
a)

b) -5.0

c) NaN

d) Logical error

Page 5 of 10
ot
output
the
Write"MANAGE
ví)
a) ""science".c
b)
Question 2
any
t
Name
vii)
i) Write the Java expression for : ab + (2a - (b')
12)

ii) Evaluate the final value ofx when the Predict


initial value of x= -2: viii)
X-=+t -x+x--/x; (2] outr
void

ii)The following code segment should print the sum ofodd factors of a +ve number N. However the code
has errors. Nanme the error and fix the code so that it compiles and runs correctly.

(2]
void odd Fact(int N)

boolean oddf-false;
int i-2,sum;
while(i<=N)

oddf-(N%i==0 i%2==1)?true:false:
|
|
if(oddf)

sumt-i;
itt;

System.out.println("'Sum="+sum);}

iv) The following code segment should print the last four characters ofa word if the length of the word is

even otherwise it will display first four characters of the same word. However the code has errors. Fix the

code so that it compiles and executes correctly. [2

string wd="COMPUTER":
if(wd.length % 2==0)
System.out.printin(wd.substring(4));
else

System.out.printIn(wd.substring(0,3));

willbe returned? (2)


v) How many times the following loop execute? What value

int callme){

int x=2,y=40;

do
c+t;
x+=x+t;
y--x++ % --y;
}while(x<y);
return X+y;

Page 6 of 10
vi) Write the output ofthe following code segments: (2]
a)
"MANAGE".compareTo("MANAGEMENT")
b) "science".charAt(3)+india".lastIndexOf('i')

vii) Name any two keywords in JAVA used as default value to initialize instance data membersof a class.

(2)

vii) Predict the output of the following code snippet:(Show dry run) (2]
void outputX)
{
int x=5,y-8;

while(t+-+x<y--)
{
if(xty<15)
x+=x+t
if(y%3!=0
y--y % x;
|
+ 7/5/3:
x!=y+2)

System.out.printin("Value="+xty);

System.out.printin("Final Value="+xty);

ix) What is the need of Wrapper class in Java? Write any one method prototype of Character class.

(2]

x) Let A[)= {12,11,8,5} and B| ]={4,5,6,7,8}


Place all the elements which are either divisible by 2 or 3 from both the arrays A and B and store them in

(2)
third array C[).

a) What will be the size of the array CU?


maximum and minimum value in array C[].
b) Write the absolute difference of

Page 7 of 10
B
SECTION this Scction.)
from
any four
questions or any program
(Answer environment
Bluel
in either
of the programs of the
consist the base logic
should as thatthe
in this section
codes so
with java
The answers environnment
description
/mnemonic
using variable
be written
Each programshould is clearly
depicted.
program not required.
are
and algorithms
Flowcharts

guéstion
3
description:
having the following
taximeter
Define a class
variables
Data members/instance

taxino -to store taxi number


String

passenger's
name
name - to store
String

kilometres travelled
km to store number
of
int -

Member functions:
to initialize the data members
taximeter)-- constructor

be positive)
String ), name(String) and ,km(must
input) - tostore taxino(

conditions kilometers travelled


to given
for a customer according
calculate) - to calculate bill

Rate/km
(km)
Rs 25
Up to 1 km
Rs 10
Next 5 kms

Rs 15
Next 6 km
Rs 20
Next 6 km

>18 km
Rs 25

travelled and Bill amount


To display the details in the following Taxino, Name,Kilometres
display()-

the above methods in it. [15]


Create an object in the main method and call all

Page 8 of 10
4:
Ouestion

Ivrite a program which


inputs u
combinations, which positive natural
when ad@ed number N and prints
give N. the possible consecutive number
A positive |15]
natural numbe (fore.g 27)can be
2+3+4+5t6+7 represented as follows
8+9+10
13+14

QMestion 5

Write a java program tofind the longest


palindromic substring from a given string.
Return the substring

Expected Ouiput:

Original string:
abcdesdfafbccb

Longest Palindromic Substring from the given string? bccb |15]

uestion 6
Write a program to accept the weight of N persons in an array. Sort the
array in descending order using
selection sort logic . Print both the original and sorted array. Now find the
average weight and print the
number of persons who weigh less than the average weight. [15]

The class declaration is as follows:

Class Name :Weight

Instance variable

N:No. of persons

w]:an array to store the weight of N persons

Weight(int no) :
Constructor to assign N by no and allocate memory for the array

accept() :Accept weight from user. They must be positive

descending order. Display the sorted array


sort) :print the original array. Sort the array in

Wts():calculate and display average weight()and print the number of persons who weigh less than the
show
average weight.

No need to write main().

Page 9 of 10
Question 7

Create a 2dimension array size m


of and n. Accept only 2 digit elements
special matrix if the sum
in it. The matrix will be called á
ofelements in the lst and last row is cqual. Check whether the created matrix is
special or not.

Example: if m=3 and n=3

Required matrix:

10 12 30
20 40 11
30 10 12

It is a special matrix (As you can see that sum of elements of row and
1 3 row(last row) is 52).

|15]

Question 8
Define a class to overload the method check as
follows:
[15]

void check(String str, char ch)print the characters which


are bigger than character ch in the String
str. Print only one occurrence of the character

Input: str ="any success" ch='e

Output :"ny sue"

void check(String str)print the vowels and consonants in alternative order. It will start either with
vowel or consomant as it is present in the string.The remaining vowels or consonants will be added at
the end.Assume str is taken in capital letter

Input : "0CCURRENCE"

Output : “0CUCERERNC"

Page 10 of 10

You might also like