Page 142 - CA_Blue( J )_Class10
P. 142
19. What will be the output of the following code?
int age = 25;
if (age < 18)
{ System.out.println("Child"); }
else if (age < 30)
{ System.out.println("Young Adult"); }
else if (age < 50)
{ System.out.println("Adult"); }
else
{ System.out.println("Senior"); }
a. Child b. Young Adult
c. Adult d. Senior
20. What will be the output of the following code snippet if day is set to 5?
int day = 5;
switch (day) {
case 1:
System.out.println("Monday");
break;
case 2:
System.out.println("Tuesday");
break;
case 3:
System.out.println("Wednesday");
break;
default:
System.out.println("Invalid day");
}
a. Monday b. Tuesday
c. Wednesday d. Invalid day
Answers
1. b 2. a 3. c 4. b 5. c 6. b 7. c 8. d 9. a 10. b 11. b
12. c 13. b 14. c 15. d 16. c 17. b 18. a 19. b 20. d
B. Fill in the blanks.
1. The ………………… statement is used to exit from the switch block.
2. The if((a>b) && (c>a)) statement returns true when ………………… is the greatest number.
3. The ………………… statement is mandatory in the switch block apart from switch.
4. The "if…else…if" statement is a ………………… flow of control.
5. The "switch" block is a ………………… statement.
6. The "if(a==0)" statement returns a value of ………………… data type.
7. Some statements within a block are together known as ………………… statement.
8. The "if(n%10==0)" statement checks that the number n is ………………… with 10.
9. We can omit the ………………… statement from the switch statement.
10. The "if" statement within another "if" statement is known as ………………… if statement.
Answers
1. break 2. c 3. Case 4. Conditional 5. Multiple branching
6. boolean 7. Compound 8. Ending 9. break 10. Nested
140140 Touchpad Computer Applications-X

