21. What is the result when you compile and run the following code?
int i = 100;
switch (i) {
case 100:
System.out.println(i);
case 200:
System.out.println(i);
case 300:
System.out.println(i);
}
[a] Nothing is printed
[b] Compile time error
[c] The values 100,100,100 printed
[d] Only 100 is printed
Answer
[c] The values 100,100,100 printed |
22. What is the result when you compile and run the following code?
int i = 100;
switch (i) {
case 100:
System.out.println(i);
break;
case 200:
System.out.println(i);
break;
case 300:
System.out.println(i);
break;
}
[a] Nothing is printed
[b] Compile time error
[c] The values 100,200,300 printed
[d] Only 100 is printed
Answer
[d] Only 100 is printed |