0% found this document useful (0 votes)
21 views6 pages

Prefinal 2025

The document is an examination paper divided into two sections, with Section A consisting of multiple-choice questions and Section B containing programming tasks. Section A includes 20 questions worth 40 marks, while Section B requires answers to any four questions from a list of programming-related tasks. The tasks involve defining classes, implementing algorithms, and performing calculations in Java.

Uploaded by

revheadz82
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)
21 views6 pages

Prefinal 2025

The document is an examination paper divided into two sections, with Section A consisting of multiple-choice questions and Section B containing programming tasks. Section A includes 20 questions worth 40 marks, while Section B requires answers to any four questions from a list of programming-related tasks. The tasks involve defining classes, implementing algorithms, and performing calculations in Java.

Uploaded by

revheadz82
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/ 6

This Paper is divided into twoSectlons.

Attempt all questlons from Section Aand any four questions from Soction B.
The Intended marks for questlons or parts of questions are glven in brackets [1
SECTIONA(40Marks)
Attempt all questions
Question 1: Multiple Choice Questions [20]

19 (1]
1. Name the method of SEARCH depicted in the given plcture Search element:

6 19 2
2 13

C) Selection sort
A) Binary search D) Linear search
B) Bubble sort

acquires |[1]
2. Name the element of object oriented programming language whereone class
the properties of another class.
B) Inheritance
A) Polymorphism D) Class
C)Abstraction

following is the feature |1]


3. Java byte code can run on alloperating systems. Which of the
mentioned?

A) platform independent B)platform dependent


D) robust and secure
C) multithreaded

letter 'A' with '#.select the (1]


4. Sam was asked to encode a string $,by replacing the
appropriate statement.

A)S.replace (#, 'A') B) S.replace('A')


C) S.replace ('A','#") D)S.replace (#")

[1]
5. In the following code
int n=3,k=5;
System.out.println (( double )(n +k)/2); statement ?
print
What type of typecasting shown in the
B) explicit
A) implicit D) error in printing
C) possible loss of precision

instance variable and the class variable is [1]


6 The keyword that distinguishes between
B) public
A) void D)global
C) static

Page 1 of 6
program Is
during the execution of the
7. The error which appears
B)syntax error
D) Runtime error.
A) logical error
C)class error
Math.max (-6.35, -15.75 ) ) )
is [1]
statement (Math.floor (
8 The output of the java
B)-6.0
A)-7.0 D) 7.0
C) 15.0
is (1]
.compareTo(" SOLUTE")
9 The output of the java statement "sOLDIER"
B)-17
A) -4 D)0
C) 17
[1]
of different data types.
Assertion (A):An array can store elements the same data
data type with multiple values of
10
Reason (R):An array is user defined
type but different memory allocation.
Reason R are true
A)Assertion Ais true Reason R is false B)Both Assertion Aand
Reason R are false
C) Assertion A is false Reason R is true D) Both Assertion A and

[1]
The output of the java statement:
11 ("BINDING". substring(0,4) );
System.out.printin ("DYNAMIC". substring (0). concat
B) DYNAMICBIND
A) DYNAMIC IND D) DYNAMICBIN
C) DYNAMICING

[1]
12. The method to check for a blank space is

A)Towhitespace ( char ) B)Whitespace (String )


C)toWhitespace (char) D) isWhitespace (char )

(Integer.parselnt ("45" ) +45 /9)); 1]


13. The output of the java statement System.out.printin
A) 50.0 B) 5
C) 10 D) 50

The method to stop the execution of the class is


[1]
14.

A) break B) continue
C) System.exit( ) D) System.exit(0)

15 The method to convert the uppercase character to lowercase is [1]


B) Character.toLowerCase( )
A) String .toLowerCase () D) tolowerCase ( char )
C)Character.tolowerCase (char)

16. int f=10, m=9 ; String c =(m %f==9)? "yes":"no"; What is the result of c? (1]

A)YES B) yes
C) No D) no output

Page 2 of 6
bytes. 1]
and 4 columns occupies
17. An array whichstores integers in 5rows
B)20 bytes
A) 80 bytes D) 40 bytes
C)160 bytes
characters, which of the following is the correct [1]
18. single dimensional array has 45 to H'
A index
statement to initialize the last
B) x[44J=H
A) x[45]=H D) x(46j='H
C) x[43]='H'
[1]
to String is
19. The method to convert adouble value
(double )
B) String.valueOf
A) Double.String( ) D) double.toString ( String )
C)Double.valueOf( )
obiect is created and initialises the
instance variables [1)
an
20. Method which is invoked whenever
with their default values is
B) Default constructor
method
A) Method D) Wrapper class
C) Parameterized constructor
[20]
Question 2: [2
i. a t V3c
Write java expression for :
[21
answer the questions given below:
ji. Consider the following array and
15,17){16,17,13,22 ))}:
int x(][ ]={{4,5,6,7) (9,3,
index of 13?
a) What is the
1][2] +x[0][3]?
b) What is the result of x[
(2
value of x =5,y =2
Evaluate the given expression when the

*y+-X;
X-=++x + --y+x
loop using do while
iv. Rewrite the following for
-=3)
for( k= 15;k>=5; k
System.out.println(k);
System.out.println(k*2);
21
using if...else
Rewrite the following ternary operator statement
V.
code==G'? "Pass": "workhard";
String z =code=='g' ll

Page 3 of6
v A
student executes the following program segment and gets an error.
The program segment checks for the equality of two values, ldentify the 24\
statement/s which has erroris, Correct the same to get the output as 100.
if( x=y)
z ==100;
else

z=200;

vii. How many times willthe following loop execute? Write the
output of the code. [2
int x=5,y=4;
while (x <7)
{t+x;
System.out.println( x*y):
yB=2;

vii. What are the values stored in the variables m and n?

i) double m=Math.abs (Math.min (-45,-75) );


i) double n= Math.ceil ( 15.6) + Math.pow (25, /,);

ix. Give the output of the following code: 2

String A= "169", B="10":


String D= B+"20";
double z=Math.sqrt (Double.parseDouble (A ));
System.out.println (D + "t" +z);
X. Writethe output of the following String methods: (21

String K= "COMPROMISE", L "COMPROMISES":

i) System.out.println (K.startsWith ( L.substring(0,4) ):


i) System.out.printn (K.compareTo (L )) :

Page 4 of6
SECTIONB
Answer any four of the following
2 For each program write the list of variables /comment statements

Question 3: [15]
Magic Decorative Light stores is offering discounts on various types of products
purchased by its customers. The following table shows the types of articles and their
respective codes along with the discount offered.
Purchase amount Discount onchandeliers Discount on Luxury LED lights
Code -C Code-L
10000 -20000 6% 3%
>20000 6.5% 4%

Define a class with the following specifications:


Class name : magic
Member variables :

double pamt - purchase amount


char code - code of the item as mentioned above in the table
double discount - discount
double bill amount to be paid
Member methods:
the type of the code from the user
void accept (): to accept the purchase amount and
using Scanner class methods only
billto be paid by the customer as
void calculate (): to calculate the discount and the
per the specifications given in the table

void display ():to print the bill to be paid as follows


YOUR BILL AMOUNT IS Rs.

the methods
void main( ): to create an object of the class and invoke

Question 4:
(15]
search for the given
Define a class to initialize the following characters in an array and
character using BINARY SEARCH TECHNIGQUE.
'K' 'M'c 's' n
"G'

[15]
Question 5: word of the given
Define a class to accept aString and print the Cipher word [a secret
word]. An Cipher word is created asa new String as follows :

willthe first letter and the


If the length of the String is even then the Cipher word
last letter of the word.
the first letter, middle
’ If the length of the String is odd then the Cipher word is
letter and the last letter.
Cipher word = RPT
Example : S= "RESPECT" length =7 [odd] Cipher word = CE
$="CUTE" length =4 [even ]

Page 5 of 6
(13]
QUESTION 6:
the method display as follows:
Define aclass to overload
following pattern USING NESTED LOOPSONLY
void displayl ) :to print the
15 14 13 12
11 10 9 8
76 5 4
series
):to print the sum of the following
double display (int x,int n, int m

11

[15]
Question 7:
[ representing
5 floors (representing the rows ] with 5shops in each floor sale made
Value zone mall has same, accept the
an array to representthe column] and the floor [
thecolumns ]. Define a class to declare the shop [
by each shop in each floor in the array. Print the details of
the maximum sale.
row]which has made

Question 8:
not. [15]
check if it is an Armstrong number or
Define a class to accept a number and
cubes of each digit is the number
itself.
number is Armstrong if the sum of the
A
Example: 153 -> 13+53+33 =1 + 125+ 27 =153

Page 6 of 6

You might also like