Menu
Topics Index
...
`

Lamp is2616


If you need explanation Read this topic

If you need Answer Take test on this topic

Lamp is2616
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.

answer is a because or operation results true and operation results false

Posted by Shiva Goud    2014-06-02 13:46:11


A is ans.as on performing logical || we get true and on logical && we get false.

Posted by Shabaaz Shaikz    2014-06-02 13:46:37


Answer : A
-> Conditional OR returns true coz one of the variables  is true
-> Conditional AND returns false coz  only one  of the variable is true

Posted by Deepak Kumar Yadav    2014-06-02 13:52:10


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

Posted by Merit Campus    2014-06-03 04:32:13


© meritcampus 2019

All Rights Reserved.

Open In App