Menu
Topics Index
...
`

Rabbit Donkey Leporidae


If you need explanation Read this topic

If you need Answer Take test on this topic

Rabbit Donkey Leporidae
What will be the output of the following program?
class Animals
{
    public static void main(String [] args)
    {
        boolean rabbit = true;
        boolean donkey = false;
        boolean leporidae = true;

        if (rabbit & donkey | donkey & leporidae | donkey)
            System.out.print("DOG ");

        if (rabbit & donkey | donkey & leporidae | donkey | rabbit)
            System.out.println("CAT ");
    }
}

A. DOG
B. CAT
C. DOG CAT
D. The program executes but there is no output. 
E. Compilation 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.

B.is the answer.as only 2nd if is true..

Posted by Shabaaz Shaikz    2014-02-10 13:01:46


B. For boolean variables , bitwise operators are logical operators.

Posted by Siddartha Reddy    2014-02-10 14:45:45


ans is B. because in 'OR' operation even if one is true then that vl be true..so it will print CAT

Posted by Varun Kumar    2014-02-10 16:45:21


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

Posted by Merit Campus    2014-02-11 03:43:00


:-) tq MC

Posted by Shabaaz Shaikz    2014-02-11 08:17:22


© meritcampus 2019

All Rights Reserved.

Open In App