What is the result?


What is the result?
A. Hello Log 1:0
B. Hello Log 2:1
C. Welcome Log 2:1
D. Welcome Log 1:0

Download Printable PDF. VALID exam to help you PASS.

2 thoughts on “What is the result?

  1. Answer C:

    In the if statement, x++ will be executed only AFTER the execution of the whole line, while the ++y will be executed BEFORE the execution of the whole line. This is because x++ is a post-increment (meaning it will be increased after the current operation), while ++y is a pre-increment (meaning it will be increased before the completion of the current operation). Here, “the current operation” is the if statement. Therefore, in the if statement, the value of x remains 1 as it is, while the value of y becomes 1. So the if statement returns false, making it jump to the else statement. Now since the if statement is now executed, the x++ will be executed, and x gets the new value, 2. Therefore, it will print Welcome Log 2:1.


Leave a Reply

Your email address will not be published. Required fields are marked *

The reCAPTCHA verification period has expired. Please reload the page.