Menu
Topics Index
...
`

Lamp is


If you need explanation Read this topic

If you need Answer Take test on this topic

Lamp is
What will be the output of the following program?
public class Switch {
    public static void main(String[] args) {
        boolean lampX = false, result;
        boolean lampY = true;
        result = lampY && lampX;
        System.out.println("Lamp switch-on " + result);
        result = lampY & lampX;
        System.out.println("Lamp switch-on " + result);
    }
}

A. Lamp switch-on true
Lamp switch-on false
B. Lamp switch-on false
Lamp switch-on false
C. Lamp switch-on false
Lamp switch-on true
D. Compilation Error or Runtime Error
Topic: Short Circuit Logical Operators 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 since and operation is true when true &&true ans bit wise operator also

Posted by Bharath Yelchuri    2014-03-12 12:58:51


Ans is B logical and operator and bitwise operator in the prob results false

Posted by Naga Sinst    2014-03-12 13:27:54


Ans is B First result is false as both the inputs i.e , lampX and lampY are not TRUE and so is with the second with result

Posted by Deepak Kumar Yadav    2014-03-12 14:42:50


c

Posted by Adithya Aleti    2014-03-12 15:11:13


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

Posted by Merit Campus    2014-03-13 04:27:57


© meritcampus 2019

All Rights Reserved.

Open In App