What will be the result of compilation and execution of the following code:

public class Main {
    public static void main (String []args) {
        int i = 0;
        i += i++;
JLS $15.7.1. Compound assignment operator is equivalent to i = i + i++ and is executed accordingly.
i will be incremented after evaluating the expression but before the assignment.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Sign Up Now
or Subscribe for future quizzes