Java Nested Conditional Logic
Consider the following code segment. Which of the following strings could NOT be printed when the code is executed?
int num = /* some integer value */;
if (num > 0) {
if (num % 2 == 0) {
System.out.print("Even");
if (num > 10) {
System.out.print(" Large");
}
} else {
System.out.print("Odd");
if (num < 10) {
System.out.print(" Small");
}
}
} else {
System.out.print("Zero or Negative");
}
A
Zero or Negative
B
Even Small
C
Even Large
D
Odd Small
Question Leaderboard
Not enough data yet to show leaderboard.
