21. In Java, what is the purpose of the "if-else if-else" statement?
22. What is the output of the following code snippet?
int n = 5;
for (int i = 0; i < n; i++) {
System.out.print(i + " ");
}
int n = 5;
for (int i = 0; i < n; i++) {
System.out.print(i + " ");
}
23. In Java, which loop is used when you want to execute a block of code at least once?
24. What does the "else" statement in an "if-else" statement block indicate?
25. In Java, what does the "continue" statement do in a loop?
26. What is the purpose of the "break" statement in a "switch" statement?
27. In Java, what does the "default" case in a "switch" statement do?
28. What is the output of the following code snippet?
int p = 3;
switch (p) {
case 1: System.out.print("One");
case 2: System.out.print("Two");
default: System.out.print("Default");
}
int p = 3;
switch (p) {
case 1: System.out.print("One");
case 2: System.out.print("Two");
default: System.out.print("Default");
}