Class X COMP 23 Mock
Class X COMP 23 Mock
Question 1. [20X2=20]
(c) Which of the following option leads to the portability and security of Java programs?
1. Polymorphism
2. Inheritance
3. Encapsulation
4. None of these
(d) Evaluate the following Java expression, if x=4 then find x+=(x++) + (++x) + x
1. 40
2. 30
3. 20
4. None of these
(e) Find the value of x, double a = 3.75; double x = Math.floor(Math.ceil(a));
1. 4.0
2. 3
3. 3.0
4. None of these
Page 1 of 5
(g) The size of float datatype in bits =______________
1. 34
2. 8
3. 32
4. 16
Page 2 of 5
(p) Math.sqrt( ) can work only on positive literals
1. True
2. False
(q) Math.abs(6.3) = 6.3
1. true
2. false
(r) A User defined function and a constructor is same.
1. True
2. false
1. Compile error
2. ICSEICSEICSE
3. ICSE [ for infinite times]
4. None of these
Question 2. [10X2=20]
a) What is Encapsulation?
b) If a= 2, b = 4 then find x = ++a * --b + (a++ + ++b)
c) How the objects are related with the classes?
d) What is Wrapper class?
e) char a = (( 65+ 70) > 1000 ) ? (char)65: (char)70; find the value of a.
f) Find the outputs:
String a = “Malayalam”, b = “aeroplane”;
i) System.out.println((a+b).lastIndexOf(‘a’));
ii) System.out.println((a.substring(0,4)+b.substring(4));
g) What is the access specifier?
h) An array a have the elements like 4 1 8 2 3, find the output after executing 3rd iteration by using bubble sort.
i) Write the java expression of √𝑥 𝑦 + √𝑦 𝑥
j) Write one difference between of equals( ) ans equalsIgnoreCase().
SECTION B ( 60 MARKS )
Attempt any four questions from this Section. The answers in this Section should consist of the Programs in either Blue J
environment or any program environment with Java as the base.
Each program should be written using Variable descriptions/Mnemonic Codes so that the logic of the program is clearly
depicted. Flow-Charts and Algorithms are not required.
----------------------------------------------------------------------------------------------------------------------------------------------------------------
Page 3 of 5
Question 4.
Define a class named bsort which will accept 10 user given array elements, sort (Ascending) and display the array
elements by using Bubble sort. [15]
Question 5.
A Dudeney number is a positive integer that is a perfect cube such that the sum of its digits is equal to the cube root of
the number. Write a program to input a number and check and print whether it is a Dudeney number or not.
Example:
Consider the number 512.
Sum of digits = 5 + 1 + 2 = 8
Cube root of 512 = 8
As Sum of digits = Cube root of Number hence 512 is a Dudeney number. [15]
Question 6.
Write a Java program to accept a string and a choice display the like this
Sample Input: ICSE
Press 1 to display
I
I C
I C S
I C S E
Press 2 to display
I
C C
S S S
E E E E
[15]
Question 7.
Question 8.
Write a class with the name volume using function overloading that computes the volume of a cube, a sphere and a
cuboid.
Formula
volume of a cube (vc) = s*s*s
Page 4 of 5
volume of a sphere (vs) = 4/3* π* r* r*r (where π = 3.14 or 22/7)
Volume of a cuboid (vcd) = l* b* h
Question 9.
Write a program to accept a word and convert it into lowercase if it is in uppercase, and display the new word by
replacing only the vowels with the character following it :
Example :
Sample Input : computer
Sample Output : cpmpvtfr [15]
===========
Page 5 of 5