Menu
Topics Index
...
`

Operator Precedence2619


If you need explanation Read this topic

If you need Answer Take test on this topic

Operator Precedence2619
What will be the output of the following program?
public class Precedence {
    public static void main(String[] args) {
        int x = 20;
        int y = 10;
        double z = x++ - y * 7 / --y + x * 10;
        System.out.println(z);
    }
}

A. 0.0
B. 20.0
C. 223.0
D. Some other output
E. Compilation Error or Runtime Error
Topic: Java Operator Precedence And Associativity

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 : c
223.0

Posted by Sree Priya    2014-04-23 03:52:56


ans C post increment operator of x is 21 so 21 is taken as x value in the second occurrence and using BDMS rule we will get and C

Posted by Bheema Reddy    2014-04-23 04:01:13


Ans is D..213..x value incremented bt for the operation it wl give 20 only n latrer 21*10 wil happen

Posted by Uday Kumar    2014-04-23 06:02:50


20 - 7 + 210 = 223

Posted by Kishan Viru    2014-04-23 07:54:11


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

Posted by Merit Campus    2014-04-24 04:21:16


© meritcampus 2019

All Rights Reserved.

Open In App