11. What is the output of the following code snippet?
int j = 0;
while (j < 5) {
System.out.print(j + " ");
j += 2;
}
int j = 0;
while (j < 5) {
System.out.print(j + " ");
j += 2;
}
12. In Java, what does the "break" statement do in a loop?
13. What is the purpose of the "for-each" loop in Java?
14. In Java, what does the "default" keyword refer to in a "switch" statement?
15. What is the result of the following code snippet?
int k = 10;
do {
System.out.print(k + " ");
k -= 2;
} while (k > 0);
int k = 10;
do {
System.out.print(k + " ");
k -= 2;
} while (k > 0);
16. In Java, which loop is used when you want to execute a block of code as long as a condition is true?
17. What is the output of the following code snippet?
for (int m = 0; m < 5; m++) {
if (m == 2) {
continue;
}
System.out.print(m + " ");
}
for (int m = 0; m < 5; m++) {
if (m == 2) {
continue;
}
System.out.print(m + " ");
}