Question 16
Back to Exercise
What does if (x > 0); { System.out.println("positive"); } do?
- A Prints only when x > 0
- B Always prints – the semicolon is an empty if body and the block runs unconditionally Correct
- C Compile error
- D Never prints
Correct Answer: Option B
A classic bug; IDEs warn about empty statements.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!