Page 183 - computer science (868) class 11
P. 183
6. Which of the following constructs can be used for selection?
a. for b. switch
c. if-else d. Both b and c
7. How many times the following loop will run?
for(i=1; i<=10; i=i*2)
a. 1 b. 2
c. 3 d. 4
8. What will be the output of the following code?
int c=2;
switch(c)
{
case 1: System.out.print("one");
case 2: System.out.print("two");
break;
case 3: System.out.println("Wrong choice");
}
a. one b. onetwo
c. wrong choice d. two
9. What type of selection statements can be used in Java?
a. single-branch b. multiple case
c. Both a and b d. None of these
10. Which of the following checks the condition before executing the body of the loop?
a. Entry controlled loop b. Exit controlled loop
c. Top-down approach d. None of these
Answers
1. d 2. a 3. c 4. d 5. b 6. d 7. d 8. d 9. c 10. a
B. Fill in the blanks:
1. When a switch case is used under another switch case, it is called ………………… switch.
2. ………………… and ………………… are entry-controlled loops and ………………… is an exit-controlled loop.
3. ………………… method finds the largest integer value which is less than or equal to the argument passed to it.
4. When no match is found in a switch statement, the ………………… case is executed.
5. The ………………… statement in Java is used to end the current iteration in a loop and continues the flow of the program.
6. The ………………… value is the positive value of the parameter.
7. The random() method in Java returns the random value between ………………… and ………………… .
8. The Java ………………… class contains a set of trigonometric functions.
9. We use ………………… to specify a new test condition in the if statement when the first condition is false.
10. The ………………… loop will always be executed at least once even if the condition is false.
Answers
1. nested 2. For, while, do-while 3. Math.floor() 4. default 5. continue
6. absolute 7. 0 and 1 8. Math 9. else if 10. do-while
C. Answer the following questions:
1. What are the three categories of statements?
Ans. The three categories of statements are:
1. Expression Statements
2. Declaration Statements
3. Control Statements
181
Statements and Scope 181

