Computer Application - Rehearsal Examination - 2023-24
Computer Application - Rehearsal Examination - 2023-24
COMPUTER APPLICATIONS
(20)
Question 1
given options.
Choose the correct answers to the questions from the
(Do not copy the qu~ on, write the correct answers only.)
picture:
(i) Name the feature of Java depicted in the following
Page 1 ofll
(a) Abstraction
(b) Encapsulation
(c) Inheritance
(d) Polymorphism
•
owing:
(ii) Predict the out put of the foll );
5,0.5) + Math.floor(2.03-17 .59)
System.out.println( Math.pow(62
(a) 41.0
(b) 9.0
(c) 9
(d) 10.0
t a correct statement?
(iii) Which of the foll ow ing is no y.
new ope rat or to initialize an arra
(a) It is always necessary to use d by curty
be init iali zed using com ma separated expressions surrounde
(b) Array can
braces.
me mo ry can be allo tted in one
statement.
(c) Array can be declared and
t.
(d) All the statements are correc
method name, what
the re are mu ltip le definitions of the method wit h the same
(iv) When answer}
diff ere nt fro m eac h other? [Choose the mo st app rop riat e
makes the m
(a) Method prototype
(b) Method signature
(c) Method name
(d) Method body
•
Page 2 of 11
(v) Choose the odd one:
(a) ==
{b) <=
(c) 11
(d) I=
(vi) If m=9 and n=6, calculate the value of the following expression.
m-=m++ --n+m
(a) -5
(b) 5
(c) O
(d) 20
(viii) What are the extensions of the Java source code and byte code flies?
{a) .java and .byte
(b) .java and .obj
(c) .Java and .class
(d) .java and no extension(because the bytecode is not stored In the form of flle)
Page 3 of 11
the correct answer:
(x) Read the following text and ' h oose
embers permitted by each modifier.
The following table shows the access to m
I Access Levels I
j Modifier ]~~ackag~~ubclas~[world]
jpublic ID[v ]fr ][:]
JD~ ]~ ]~
ir j
jprotected
jno modifier j[N
jprivate \~=:JIN ](N ]N
The first data column indicates whether the class itself has access to the member defined
by the access level. As you can see, a class always has access to its own members. The
second column indicates whether classes in the same package as the class (regardless of
their parentage) have access to the member. The third column indicates whether
subclasses of the class declared outside this package have access to the member. The
fourth column indicates whether all classes have access to the member.
[Source: The Java Tutorials (Oracle Official w~bsit~}}
Through this type of access modifier, the members of the class are accessible to the same
class or package or subclasses in different package but not to any other class or package.
(a) public
(b) protected
(c) default
(d) private
Page 4 of 11
(xH)What ls the final value of ctr h h .
w en t e iteratio n process given below executes?
Int ctr--0;
for(lnt 1=1;1<=5;1++)
for(lnt J=1;J<=S;J+=2)
ttr=c:tr+l;
(a) 25
{b) 10
(c) 1
(d) 15
Page 5 of 11
n,
(xvi) Arrange the following variables according to their size In memory l•scet\d1
order).
Iona 1&•5;
boolean bl=true ;
char ch::'9'; float ft=2.05f;
(a) bl ch ft lg
(b) ch bl ft lg
(c) bl ft lg ch
(d) ch ft bl lg
(xvii) Which of the following can be used for a variable name in Java?
(a) A-to-Z
(b) 2023Java
(c) static
(d) Class
(xviii) Assertion(A): Size of the array can be changed after it is declared or lnlttallzed.
Reason(R): Java array is an object which contains elements of a similar data
type. The elements of an array are stored in a contigu ous memo ry
location. •
explan ation
(a) Both Assertion (A) and Reason (R) are true and Reason (R) is a correct
of Assertion (A)
not a correct
(b) Both Assertion (A) and Reason (R) are true and Reason (R) is
explanation of Assertion (A)
(c) Assertion (A) is false and Reason (R) is true
(d) Assertion (A) is true and Reason (R) is false
(xix) Name the type of the error, if any in the followin g statement:
double discount=40/100*price;
t and the
[Here, price is a double type variable which stores the price of a produc
409' discount is given on
above statem ent is used to calculate the amoun t of discount when the
the produc t]
Page 6 of 11
(xx)What will be the output of the following code segment?
Int arr[]= { 0, -1, -2, -3, -4, -5, -6, -7};
for( Int z = 5 ; z > 2 ; z •= 2) {
System.out.prlntln( arr[-z1 ); }
(a) -s, -3, -1
(b) -4, -2, O
(c) -4
(d) -4, -2
Question 2
(I) What will be the output of the following code snippet (show the steps)? (2)
Int a1=4,a2=5,a3=6;
boolean f;
f = al - a2 • a3 >= 2 && a3 +al I= Math.abs(a1-a3);
System.out.prlntln(f);
class ldentffyParts
{
double dd=34.01;
static Int xx=10;
lntyy=23;
Page 7 of 11
puter Applications..,. Howe
ver, tht r,
. . tis used to display NCom modified cod e. Wh td,
WJ ng ~e snappe ·ty the error(s) and rewrite the [ )
(v) The follO Rect1 2
is/are error(s) in the code.
of err or is It?
double choice=1.0;
switch(choice)
mputer ");
{ case l.O: System.out.prlnt("Co
Appllcatio ns");
case 2.0: System.out.prfnt("
break;
rong choice");
default: System.out.println("W
}
(2]
the foll ow ing 20 array:
(vi) Consider }, {7,8,9} };
Int array[]a ={ {1, 2,3 }, {4,5~6 d ou t the sum of the
a single Java sta tement using the index positions to fin
(a) Write
diagonal of the 20-array.
elements placed on the right
ay given above?
(b) What is the size of the arr
the Character
ase () me tho d is de fined in the String class as well as
(viii) The toLowerC of the toLowerCose( )
Wr ite any 2 differe nce s between these tw o types
wr ap pe r class. (2]
h the he lp of exa mp les.
me tho d wit
exampie.
ove rlo ad ing be achieved? Explain wit h the help of an
r
(ix) Ho w can the constructo [2]
n as parameters
me d po we r() wh ich accepts 2 integer variables a and
(x) Wr ite a me tho d na
ue of a" wit ho ut using
an int eg er value . Th e method calculates the val
an d returns [21
/Full pro gra m Is no t needed]
Ma th. po w( ).
Page 8 of 11
I
The answers in this section should consist of the programs in eitMr Blue.J
environment or any program environment with java as the base.
,~estton3 llSl
A car rental company rents out 4-wheeler cars on hourly basis. Define a class with the foUowing
specifications:
Member methods:
void accept( ) - accept name, driving license and hours using methods of Scanner da~s.
void calculate( ) - Calculate the bill amount to be paid by the customer as per the foltow\nt
criteria:
Hours Amount
First 5 hours Flat charge 7000
Next 3 hours 1500 per hour
Next 2 hours 1200 ~er hour
I
Over 10 hours , 1000 per hour l
If the bill amount is" 10,000 or more, then either a discount of 20% or flat~ 2500 (whkh~ \,
minimum) is applied.
Page 9 of 11
details in the follow ing format:
void print( ) - Display the Bill Am ou nt
Rent Time
Customer Name Driving License
object.
ds in main method using an
Call all the above metho
(15)
_JIGestton 4 Pa ng ram or
nv ert it to up pe rcase . Check wh eth er It Is a
a sentence. Co
Design a dass to accept let ter of the alphabet is used at least
once.
nce in wh ich every
no t. A Panaram is a sente
ov er a lazy do g
le Inp ut: Th e qu ick bro wn fox jum ps
Samp
It is a Pangram
Sample Output:
least once]
I A - Z all alphabets are present at
ps ov er a dog
Sa mp le Inp ut: The qu ick bro wn fox jum
•
Sa mp le Ou tpu t: It is no t a Pangram
(1S)
Question 5
ing order usin&
s in a do ub le- typ e array. Sort them in ascend
N value
Define a class to accept array.
e and display the sorted
Selection Sort techniqu
{151
ye st io n 6 ximum value of
o a 3x3 array of int eg er typ e. Display the ma
values int
Define a class to accept
value of each column.
each ro w and mi nim um
Page 10 of 11
7
/uestf on
(15]
Write a program to input an Integer and check Whether It is an Armstrong number or not.
An
digits.
Armstrong number is a positive n-digit number that is equal to the sum of the n powers of their
th
Example:
9 '? !Jl = 9 (Armstrong number)
153 13 +53 +33 = 153
(Armstrong number)
371 33 + 73 + 13 = 371
(Armstrong number)
1 +6 + 34 +44 = 1634
4
1634 4
(Armstrong number)
92727 25 + ]5 +25 + ]5 = 92727
(Armstrong number)
Question 8
(15]
Define a class to overload the metho
d pattern( ) as follows:
(
void pattern char x,char y) - Display the following pattern.
'@' d
Sample values: x= • on y='$'
Output: (Ip
§)$
(§1$(11
@$(11$
1)$@$(§1
(§1$(11$@$
Wrrte
• a ma,·n method to create
• an o bJ"ect of the class and invoke t he member methods.
[This• quesu
"on paper consists
• 'J 11 printed sides.]
of
Page 11 of 11