Menu
Topics Index
...
`

Output is2608


If you need explanation Read this topic

If you need Answer Take test on this topic

Output is2608
What will be the output of the following program?
public class ShortTest {
    public static void main(String[] args) {
        boolean x = true;
        boolean y = false;
        if (x && y) {
            System.out.println(true);
        } else {
            System.out.println(false);
        }
    }
}

A. true
B. false
C. Compilation Error
D. Runtime Error
Topic: if Condition 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 B..here we have the logical and operator..it wil give true if both the expresdions is true...here we have the 2 boolean variables...x=true n y=false...here it will give false so else condtion will get executed...

Posted by Uday Kumar    2014-12-01 04:07:35


ans b bcz
In the given program,here 2 boolean variables initialized one with  true and other with false
x&&y=>true&& false=>false
so if condition does not satisfy and else results in print statement of false

Posted by Pooja Singh    2014-12-01 04:08:46


b.... here we r usng logical && oprtr... rules r -> for x&&y if x is false den it wil nt chk fr y n rslt is false..,. if x is tru den th answr wil dpnd on y....here x= TRUE SO IT WIL CHK FR Y AS Y IS FALSE HEMCE IT WIL NPT EXECYTE IF PART N GO TO ELSE PRT N PRNT FALSE

Posted by Asma Mujtaba Khan    2014-12-01 04:31:07


This dose is now closed and the winners are Uday Kumar,  for 'First Correct Comment', Sai Ram,  for 'Best Comment' and Uday Kumar for the 'Popular Comment'. The 'lucky liker' is Varun Kumar. Please login into Merit Campus using facebook, to claim your recharge. Go to http://java.meritcampus.com/earnings to raise the recharge.

Posted by Merit Campus    2014-12-02 03:52:56


© meritcampus 2019

All Rights Reserved.

Open In App