Menu
Topics Index
...
`

Operator Precedence


If you need explanation Read this topic

If you need Answer Take test on this topic

Operator Precedence
What will be the output of the following program?
public class OperatorPrecedence {
    public static void main(String[] args) {
        int a = 7 * 3 + 24 / 3 - 5;
        int b = (7 * 3) + (24 / 3) - 5;
        System.out.print(a + ", " + b);
    }
}

A. 24, 24
B. 33, 24
C. 33, 33
D. Compilation Error
E. 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.

A
it is jst the normal precedence operation.
a = 21 + 8 - 5 =24
b = 24 + 8 - = 24

Posted by Bhalkiker Badrinath    2014-01-14 04:40:14


A

Posted by Ravikiran Chowdary    2014-01-14 04:46:52


A
A=21 +8-4=24
And b=21+8-5=24
So 24,24

Posted by Sreenath Vallapaneni    2014-01-14 05:05:12


a=21+8-5;

Posted by Siva Kumar Sudarsi    2014-01-14 06:15:56


a=21+8-5   --> 21+3=24    , b=  (21)+(8)-5   -->  21+3=24    So  a= 24 ,b= 24 .

Posted by Siva Kumar Sudarsi    2014-01-14 06:17:18


A

Posted by Bhagya Lakshmi    2014-01-14 07:30:11


D

Posted by Venkateshwarlu Neredukomma    2014-01-16 05:23:00


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

Posted by Merit Campus    2014-01-16 08:47:41


A

Posted by Shravan Kumar    2014-01-16 15:36:26


© meritcampus 2019

All Rights Reserved.

Open In App