Page 235 - CA_Blue( J )_Class9
P. 235
Unsolved Questions
A. Tick ( ) the correct answer.
1. int i=1, s=0;
do
{ if(i%4==0)
{ System.out.println((i*2) + ",”); }
i++;
} while(i<=10);
What is the output of the above program snippet?
a. 4,8 b. 8,16
c. 1,2,3,….,10 d. None of these
2. "for(i=10;i>=1;i++)” loop is a __________ loop.
a. exit b. entry
c. infinite d. finite
3. The following program segment prints:
int a=5,b=2;
do
{
if(a>b)
{
a=a+1;
b=b*2;
}
}while(a==0);
System.out.print(a+ ":" +b);
a. 6:2 b. 6:3
c. 6:4 d. 6:1
4. What will be the output of the following code?
(i) int m = 2;
int n = 15;
for(int i = 1; i < 5; i++);
m++;
--n;
System.out.println("m = " + m);
System.out.println("n = " + n);
a. m=3 b. m=1
n=11 n=14
c. m=3 d. Not output
n=14
B. Fill in the blanks.
1. ………………… loops have an empty loop body.
2. The two jump statements are ………………… and ………………….
3. To execute a loop 10 times, for (i=3; i<=…………………; i=i+3)
4. for (i=10; i<10, i++) loop executes for ………………… times
5. An ………………… loop checks the condition at the time of entry.
6. Both ………………… and do-while are suitable in situations where the number of iterations is not known.
Iterative Constructs in Java 233

