What is the following code execution result?

    public static void main(String args[]) {
        int a = 1;
        int b = a++;
        int c = -a;
        System.out.print(a);
        System.out.print(b);
        System.out.print(c);
    }
Explanation
The following steps will be executed in order
b will be initialized with 1
a will be incremented and will be equal to 2
c will be initialized with -2

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback