← Quiz: Java Control Flow: all 10 questions
Quiz: Java Control Flow · Question 8 of 10
What does this print? (code)
What does this print?
public class Main {
public static void main(String[] args) {
for (int i = 1; i <= 5; i++) {
if (i % 2 == 0) continue;
System.out.print(i);
}
System.out.println();
}
}
- A.12345
- B.24
- C.1
- D.135
Answer & explanation
Correct answer: 135
continue skips the rest of the body for even numbers, so only 1, 3 and 5 are printed.
Can you get the rest right without peeking?
Take the timed Quiz: Java Control Flow quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →