GREENWOOD HIGH
UNIT TEST 2 (2023 - 24)
COMPUTER APPLICATIONS
Grade: IX Time: 40 Minutes
Date: 9/12/2023 Max. Mark: 25
____________________________________________________________________________________
Answers to this paper must be written on the paper provided separately.
You will not be allowed to write during the first 5 minutes.
The intended marks for questions or parts of questions are given in [ ].
_________________________________________________________________________________
(Attempt all questions)
Question 1 : [3]
Choose the correct answers to the questions from the given options.
i) What will be the output of the following Java statement ?
System.out.println(Math.floor(Math.cbrt(Math.round(26.6))));
a) 2.0
b) 3.0
c) 4.0
d) 5.0
ii) How many times the inner and the outer loop will be executed for the following code segment ?
for(int m=0;m<3;m++)
{
for(int n=0;n<2;n++)
{
int ans=(int)(Math.random()*10);
}
}
a) Inner loop : 12 times , Outer loop : 4 times
b) Inner loop : 6 times , Outer loop : 5 times
c) Inner loop : 6 times , Outer loop : 3 times
d) Inner loop : 3 times , Outer loop : 6 times
__________________________________________________________________________________________________
UT 2 Grade IX (2023-24) Page 1 of 2
iii) What is incorrect in the following Java statement ?
for(int k=2 , k<=10 , ++k)
a) The increment should always be k++
b) loop counter must be ‘i’ and not ‘k’
c) there should be a semicolon at the end of the statement
d) the commas should be semicolons
Question 2 : [2]
Predict the output of the following code snippet:
for(int p=2;p<=6;p+=3)
{ int r=1;
for(int q=1; q<=p; q+=2)
r=q+r;
if(r==4)
break;
System.out.println(Math.min(p,r));
}
Question 3 : [10]
Write a menu driven program in Java to :
1. Display the series : 5 55 555 5555…. up to n terms
2. Find and display the sum of the series given below :
S = (1+2+3)+(2+3+4)+(3+4+5)+(4+5+6)+…… up to n terms
For an incorrect choice , an appropriate error message should be displayed .
Question 4 : [10]
Write a program in Java to print the following pattern using nested loops :
1
121
12321
1234321
123454321
1234321
12321
121
1
__________________________________________________________________________________________________
UT 2 Grade IX (2023-24) Page 2 of 2