Page 218 - Computer science 868 Class 12
P. 218
c. unfixed d. All of these
4. What keyword is used to end the current loop iteration and proceed with execution with the next iteration of that loop?
a. break b. continue
c. end d. skip
5. What is the output of the following code snippet?
int i = 0;
for(i = 0 ; i < 5; i++){ }
System.out.println(i);
a. 5 b. 0
c. 4 d. Compilation Error
6. What is the output of the following program?
class Test{
public static void main()
{
int i = 0;
for(i = 0; i < 10; i++){
continue;
}
System.out.println(i);
}
}
a. 10 b. Nothing
c. Compilation error d. 9
7. What is the output of the following code?
for(int i = 0; i < 10; i++)
{
if(i % 2 == 0)
{
continue;
}
System.out.println(i);
}
a. Program will print all even numbers between 0 and 10.
b. Program will print all odd numbers between 0 and 10.
c. Program will give a compilation error.
d. None of these
8. An if or else-if statement accepts ………………… as input before branching.
a. boolean b. int
c. float c. char
9. An else statement must be preceded by ………………… statement in Java.
a. if b. else-if
c. Both a and b d. None of these
10. A switch statement accepts ………………… type of data as input.
a. byte b. short
c. int d. All of these
B. Fill in the blanks:
1. Java Ternary operator is also called ………………… .
2. What is the output of the following code snippet?
int p=5;
p=(p<6)?5:6;
216216 Touchpad Computer Science-XII

