Menu
Topics Index
...
`

Increment Decrement Operators Output


If you need explanation Read this topic

If you need Answer Take test on this topic

Increment Decrement Operators Output
What will be the output of the following program?
class Operators1
{
    public static void main(String[] args)
    {
        int a = 34;
        int b = 21;
        int c = a++ + ++b;
        int d = --a + --b + c--;
        int e = a + +b + +c + d--;
        int f = -a + b-- + -c - d++;
        int sum = a + b + c + d + e + f;
        System.out.println("sum = " + sum);
    }
}

A. sum = 265
B. sum = 263
C. sum = 264
D. Compilation Error
Topic: Increment And Decrement Operators In Java

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

ans is B there is no compilation error because we did not taking any arguments as inputs

Posted by Adithya Aleti    2014-03-20 04:23:18


Ans is B: sum is 263, here,,   a + +b is represent as    a+(+b).

Posted by Mallikarjuna Rao    2014-03-20 04:33:54


ans is B,i.e.,263. the value of c=55,d=111,e=221,f=-178. here a + +b is treated as a + (+b).

Posted by Chintu Raparthi    2014-03-20 08:13:42


Congratulations Adithya Aleti. You are this dose winner. We will send you the link using which you can claim your recharge.

Posted by Merit Campus    2014-03-21 04:17:38


© meritcampus 2019

All Rights Reserved.

Open In App