0% found this document useful (0 votes)
25 views5 pages

Adobe Scan 7 Nov 2024

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)
25 views5 pages

Adobe Scan 7 Nov 2024

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/ 5

ST.

XAVIERS INSTITUTION PANIHATI


Half Yearly Examination 2024-25
Class - IX
Subject - Computer Applications
Maximum Marks: 100
Answers to this paper must be Written on the paper prov·1ded Time: allowed: Two Hours
• separately.
You will not be allowed to write during the first 15 minutes.
This time ls to be spent In reading the question paper.
The time given at the head of this paper is the ttme allowed tor wr'ti th
1 ng e answers.
This paper Is divided into two sections.
You are ~o answer all questions from Section A, and any four questions from Sections.
The intended marks for questions or parts of questions are given In brackets [ ).
SECTION A ( 40 Marks )

(Attempt all questions)

Question 1.
[ 20]
choose the correct answers to the questions from the given options.

(Do not copy the question, write the correct answers only.)

(i) Name the feature of java depicted in the adjoining

(a) Abstraction (b) Encapsulation (c) Inheritance (d) Polymorphism

(ii) The expression which uses >= operator is known as:

(a) relational (b) logical (c) arithmetic (d) assignment

(iii) Ternary operator is a/an:

(a) logical operator (b) arithmetic operator (c) relational operator (d) cond\t\ona\ operator

{iv) When higher data type is converted to a corresponding lower· datatvpe , it is ca\\ed:

(a) Boxing (b) Unboxing (c) Explicit type conversion (d) Implicit type conversion

(v) The number of bytes occupied by 10 characters.

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

(vi) The method of Scanner class used to accept a character yalue is:

(a) nextChar() (b) nextCharacter() (c) nextline().charAt (O) (d} none of these

(vii} Among the following which one is not a keyword:

{a) const {b) do (c) for {d) while

(viii) Math.sqrt(-1, 0.5) returns:

(a) logical error (b) syntax error (c) NaN (d) none of these

(ix) Name the type of error, if any in the following statements:

int a=S, b=O, c=a/b;

{a) syntax error (b) runtime error (c) logical error (d) no error

(x) x + = x++ + --x + -x + x; [ x = S ]

(a) 23 (b) 20 (c) 18 (d) none of these

(xi) The statement System.out.print ln(1+2+"four "+2+5); gives the output........ .


(a)3 fourt 2,.b(b)3 four 23 (c) 12 four 23 (d) error

1
..)
(.XII _ _ _ _ _ _ are the sta tem
_ en ts in a pro gra m thata re no t ex ec ute d.
la) Co mm en ts (b) Va • ti
riables (c) Variable
Oescnp on (d) Loops
(xiii) Wh en the opera . . the y are ev alu ···· ··•· "·· in th e or
tors have the same ate d fro m ............ de r th ey appe-c.
pn on ty, ..... •
the expression.
A) rig ht to lef t B) lef
t to rig ht C) any of the d o) de pe nd s on the co
or er mp ile r
(xiv) Which principle
of OOP does 'exten
ding a class' ad he re
(a) Abstraction (b) to?
Encapsulation (c) Inh
eri tan ce (d} Po lym
orp his m
(xv) Wh at wil l be the
result of the fol low
ing sta tem en t?
Sy ste m. ou t.p rin tln(
3+ 3 •3 • 3+ 3);
(a) 57 (b) 33 (c) 10
8 (d) None of the se
(xvi) Which of the
fol low ing are pri mi tiv e da
ta typ es :
i. char ii. Integer iii.
flo at iv. do ub le
(a) Only I (b) Only ii
(c) Both i and ii (d)
No ne of the se
(xvii) Assertion: In Jav
a, the "st ati c" ke yw
ord is used to de cla
class and no t to ins re va ria ble s th at be
tances of the class. lon g to th e
Reason: By using the
"st ati c" ke yw ord , the
se va ria ble s ca n be
creating an instance accessed wi th ou
of the class. t
Which op tio n corre
ctly describes the
rel ati on sh ip be tw
ee n
As se rtio n an d Re
(a) Both Assertion as on ?
and Reason are tru
e, an d Reason is a
co rre ct ex pla na tio n of As se rtio
(b) Both Assertion n.
an d Reason are tru
e, bu t Reason is no
(c) Assertion is tru e, t a co rre ct ex pla na
bu t Reason is false tio n of As se rti
.
(d) Assertion is false on .
, bu t Reason is tru
e.
(xviii) Read the fol low
ing tex t, an <ic ho os
\n lav a the "fo e th
• l"' st.a
ter ne nt \s
e co rre ct an sw er

us ed to loo p-
Wh \ch of the fo\ Ul t• &Iv e •
\ow \ng \s tru e ab n co nd itio n Is
ou t th e "fo r" sta tru e
(a) \ni t\a \\z at\ on t
in for is op tio na ern en t In Jav a? •
l
{b) Co nd itio n in for
Is op t\o na l.
(c) lnc rem en t/D ea
em en t I.e . ste p is
op tio na l.
(d) All of the abov
e.
(xix) Assertk>n (A)
: An array varlable ls als
o kn ow n as subscri
Reason (R): In arrays pted variable.
, every ele me nt is
represented wi th
(a) Both Assertion the he lp of its ind
(A} and Reason (R) ividual Index.
are tru e and Reaso
(b} Both Assertion n (R) Is a correct ex
(A) and Reason (R) planation of As se
are tru e rtion (A)
and Reason (R) ls no
(c) Assertion (A} Is t a co rre ct ex pla na
tru e and Reason (R) tio n of Assertion(A
Is false )
(d) Assertion (A) is
false and Reason (R)
ls tru e
(xx) Which of the fol . statements corre
low ing ctly describes the be
havior of the Ma th.
ran do m( ) me tho d
ath random() ret um d Integer between O in Java7
(a} M • s a ran om (inclusive) and 1 (ex
clusive).
(b) Ma th. ran do m( ) d ble between o.o
returns a random (inclusive) and 1.0 (ex
ou clusive).
(c) Ma th. ran do m( ) d m boOlean value
generates a ran o .
(d) Ma th. ran do m( ) do m lon g value.
ret urn s a ran

2
,sdon 2.
2
-r . the Java expression for y=b-i3((b -4ac))/(2a)
,, write {2]
h expression when int x=2:
~~c$),./ (ii) Evaluate t e (2)

+x·
int y=x+x++ + ++X ,
. ode segment checks if the given year is a leap year or not. ( 2]
(iii) The following c
has errors. Fix the code so that it compiles and runs correctly.
However the code
. b<>Olean isOdd(int n){
public stat1c
; boolean result = False;

if (n9'2==1) result=true;

return result;

}
[2]
{iV) Harsh is trying to determine the average of three numbers.

However the following code segment is not giving the correct answer. How the program can

be modified to get the correct answer?

Scanner in = new Scanner( System.in );

float numberl=in.nextFloat();

float number2=in.nextFloat();

float number2=in.nextFloat();

float average=numberl + number2 + number3 / 3;


System.out.println("Average is average);

(v) What will be the value of count after the ~oJlowing code segment is.executed? [21

byte count = O;

for( ;count>=O; ){

count++;

(vi) Convert the following segment into equivalent for loop. (2]
int year;

year= 2023;

while(year <= 2025)

J
{

System.out.print(year + " ");


year++;
}

System.out.pr int(" Project Completed");

(vii) Name the two reserved words which are not keywords. [2)

(viii) Name the Type of Conversion In the following statements. {2] I


a) int N = 'a';

b) Integers= new lnteger(SO);


'
if-4)

3
(ix) When th . .
er e is no explic
it initiahzano h a t are t he default values set
n, w to r
variable in th
e follo wing cases?
(a) double

(b) boOlean
(x) Convert
th e following if . w itc h case st
else statemen
~ in to s at em en t [ 2]
lf(x==l)
System.out.p
rintln("one");
else if(x==2)
System.out
.println("two"
);
else
System.out.p
rintln("errorn
);

SECTION B
(6 0 M ar ks )
The answers (Answer any
in this section fo ur questio
should cons ns fr o m th is
ist o f th e pr S ec tio n. )
pr og ram environm ograms in e .
Each program it h e r BlueJ
should be w ent w it h java e n va ro n m
rit te n using as th e ba se . ent or any
variable de
sc ri pt io n/ m
th e program ne m on ic co .
is clearly de de s so th a
Q ue st io n 3. Flowcharts an pi ct ed . t th e lo g ic
d algorithm of
s are n o t re
Input a three qu ir ed .
digit numbe
A number is riand check
said to be Ju w he th er it is
pi ter number a Jupiter nu
~ .: .: :: , ~+ if it is compl m be r o r n o
t. U si ng vo [ 151
6=7 and 126 et ely divisible id Ju p it e r(
is divisi~le by by su m o f it in t n ).
4 7. s fi rs t a n d
la st d ig it .
~ ;\ ~ a pr og ra
m en te r a
U si ng \n t po si tiv e \n
su m l\n t n) te ge r. C om
. pu te an d
~ es t. \o nS re tu rn th
. e su m o
f al l p ri m
/;,. Oudenev e di gi ts
nu m be r \s a co n ta in
e d In th
th e nu m be po sl tw e In te ge e nu na
r. W rt te a pr r th at ls a pe
ogram to In rf ec t cu be
du de ne y\ \n pu t a nu m be r su ch th a t
t n) . an d ch ec k th e su m o .
Example: an d pr in t w f its di gi ts [1 5 ]
he th er It Is is eq ua l to
co ns id er th a D ud en ey th e cu b e
e nu m be r 51 number o ro o t 0 ~
2. r n o t us in
su m of di g\ g vo id
ts = S + 1 + 2 8
=
Cube ro ot of
11,.s su m of
51 2 = 8
di gi ts = Cub t o f N um be
e ro o r he nc e 51 2
is a ou de ne
y nu m be r
Q ue st io n&
.
W rit e a m en og
u dr iv en pr ra m to pe rf or m th e fo
llo w in g op er r1.sJ
at io ns as pe
. um In t n)
li) vo id s To pr in t th e • r us er •s c ho1• e·
l su m of th e c •
S :1+{1•2 )+
{1•2 • 3)+••• •• lt•2 •3 •se ries
..................+n
lii ) vo id di sp ···;···--~~;·~ )
\lowlng serie
1 12 12 3, \a yl ) To dlsp s us in g fo r
1234,........... av ...............,1 23 45 67 lo op :
, , ...... 89
W rit e m ai n th od using .... h se st at em en
me sw\tc ca t to execute
th e above m
et od .

4
Question 7.
da s without any fine, while
Apub\ic \ibrarv \ssues books, h' h a student can use for 7 V returning the book
w ,c ed ai.er specified days.
a une w·,\\ be charged only for excess days, if return. ": l1S1
Oesign a c\a~ library with the . ificanons:
following spec
C\ass name : library
Member variables / Data mem
bers: .
bname - to store the name of
the book issued.
days - to store the number of days taken to return the book.
extra - to store the extra days
after the specified days.
fine_amount - to store the amo
unt to be paid as fine.
Member methods:
void input() - to input the nam
e of the book and the number
return the book. of days taken to
void computefine() - to compute
the extra days taken to retu
days as per the given slabs: rn the book and calculate
the fine amount only for extr
a
Extra days
Charge per day
Upto 5days
~5
6 to 15 days
~10
Above 15 days
void display() - to display the
~o
name of the book, extra day
Now define a main() method s taken to return and the fine
to create an object and invo amount.
desired output. ke the above member metho
ds for obtaining the
Question 8.

Design a Java program to calc (15]


ulate the electricity b\11 based
prompt the user to enter the on the slabs of units consum
number of units consumed ed by a user. The program should
the given slabs: in a month and calculate the
correspondfng electricity bill
For the first using
100 units, the charge is Rs.
2 per unit .
For the nex t 200 un\ts llOl
-30 0), the charge ls Rs.
For any addit\onal unit s bey 3 per unit.
ond 300, the charge is Rs.
Class Nam S per unit.
e: ElectricityBillCalculator
Data Members:
int unitsConsumed: stores the
number of units consumed
double totalBillAmount: stor by the user.
es the total bill amount to be
Methods: calcu\ated.
public void inputUnitsConsume
d(): prompts the user to ent
the unitsConsumed data mem er the number of units con
ber. sumed and assigns the valu
e to
public void calculateBillAm
ount(): calculates the total
public void displayBillOetails bill amount based on the slab
l): displays the electricity bill s of units consumed.
bill amount. details, including the number
of units consumed and the
total
Now define a main() method
to create an object and invo
ke the above member met
hods for obtaining the
desired output.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy