Menu
Topics Index
...
`

Long


If you need explanation Read this topic

If you need Answer Take test on this topic

Long
What will be the output of the following program?
public class Shock {
    public static void main(String[] args) {
        Long abc = 200L;
        Long bca = 199L;
        Long cab = 100L;
        if ((abc > bca) ^ ((cab * 3) == abc))
            System.out.print("ABC");
        else if ((bca + 1 != abc) ^ ((cab * 3) == bca))
            System.out.print("BCA");
        System.out.print("CAB");
    }
}

A. ABCBCACAB
B. ABCCAB
C. CAB
D. Some other output
E. Compilation Error or Runtime Error
Topic: Creating Objects for Primitive Data Types (Byte, Short)

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, the first if condition returns false so it goes to else if condition, the else if condition is also returns false, so finally if condition is fail to execute then the last statement will print.

Posted by Damu Surya    2014-05-23 04:54:49


ans b as the first if condition is true prints abc and it doesnot go to else and prints the next output as cab ...finally abccab is printed out

Posted by Manasa Jyothi Sree    2014-05-23 07:47:29


Ans:B OUTUP : it prints as ABCCAB  FIRST STATEMENT satisfy and goes to else if second statement

Posted by Sivani Reddy Kakuru    2014-05-23 10:35:22


Congratulations Manasa Jyothi Sree. You are this dose winner. We will send you the link using which you can claim your recharge.

Posted by Merit Campus    2014-05-26 12:44:45


© meritcampus 2019

All Rights Reserved.

Open In App