Menu
Question Index
...

What will be the output of the following program?

class IncDec
{
    public static void main(String s[])
    {
        
        int a = 1;
        int b = 2;
        int c;
        int d;

        c = ++b;
        d = a++;

        c++;

        System.out.println("a = " + a);
        System.out.print("b = " + b);
        System.out.println("c = " + c);
        System.out.print("d = " + d);
    }
}


a = 2
b = 3c = 4
d = 1
a = 2
b = 3
c = 4
d = 1
Program does not compile.
a = 1
b = 2
c = 4
d = 2

Doubts

Problems

Topic: Increment And Decrement Operators In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App