LearnFrenzy
Sign in Take a free test

Control Flow Statements · Control Flow MCQ · Question 16

A semicolon right after an if condition Answer, explanation & discussion

  • MCQ
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
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!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links