What is the result if the integer aVar is 9?

Given the code fragment:

What is the result if the integer aVar is 9?
A. Compilation fails.
B. 10 Hello Universe!
C. 10 Hello World!
D. 9 Hello World!

Download Printable PDF. VALID exam to help you PASS.

3 thoughts on “What is the result if the integer aVar is 9?

  1. Answer C:

    At the if statement, aVar++ will be executed only after the full line is executed. Therefore, when aVar is 9, it will pass the the condition and gets into the println statement. However, at this point, the aVar++ will be executed, making aVar 10. So it prints 10 Hello World!

Leave a Reply

Your email address will not be published.