← Quiz: Java Control Flow: all 10 questions
Quiz: Java Control Flow · Question 6 of 10
What does this print? (code)
What does this print?
public class Main {
public static void main(String[] args) {
int a = 0;
if (a != 0 && 10 / a > 1) {
System.out.println("big");
} else {
System.out.println("safe");
}
}
}
- A.big
- B.ArithmeticException
- C.safe
- D.Compile error
Answer & explanation
Correct answer: safe
&& short-circuits: a != 0 is false, so 10 / a is never evaluated and there is no division by zero.
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 →