Menu
Question Index
...

In which order should the lines A, B, C, D be arranged such that it gets the required output?

/* Required output
a = 4 b = 8 c = -5
*/

class OrderLines
{
    public static void main(String[] args)
    {
        int a = 27 / 4 + 9;
        int b = 52 / 6 - 3;
        int c = 3;
        c = a++ - b; // LINE A
        a = a * b; // LINE B
        b = b + a; // LINE C
        a = (a < c) ? a % c : c % a; // LINE D
        System.out.println("a = " + a + " b = " + b + " c = " + c);
    }
}


A, B, C, D
B, D, C, A
B, A, D, C
A, B, D, C

Doubts

Problems

Topic: Ternary Operator 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