Menu
Topics Index
...
`

Array declaration1900


If you need explanation Read this topic

If you need Answer Take test on this topic

Array declaration1900
What will be the output of the following program?
public class Visit {
    public static void main(String args[]) {
        int s = 123;
        boolean[] BA = new boolean[10];
        if (BA[0] == s > 333)
            System.out.println(s);
    }
}

A. 333
B. 123
C. Some other output
D. Compilation Error or Runtime Error
Topic: Creation And Declaration Of Array 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.. Default value of boolean is false s>333 becomes false so false==false becomes true so ans is 123

Posted by Sadanand Kalyankar Patil    2013-11-05 03:40:26


B. 123

Posted by Sagar Kamble    2013-11-05 03:42:27


ans is B bcause 123 > 333 gets evaluated to false and BA[0] is also false so s vaue gets printed ..

Posted by Mahesh Kumar    2013-11-05 03:49:50


ans :B because greater than(>) symbol has higher precedence than (==) .the default value of boolean is false i.e.,0 and the output from 123>333 is also 0 therefore if condition value is true and prints the value of s which is 123.

Posted by Manasa Jyothi Sree    2013-11-05 05:59:37


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

Posted by Merit Campus    2013-11-06 04:31:31


© meritcampus 2019

All Rights Reserved.

Open In App