Menu
Topics Index
...
`

Ternary Operator


If you need explanation Read this topic

If you need Answer Take test on this topic

Ternary Operator
What will be the output of the following program?
public class TryMe {
    public static void printB(String str) {
        System.out.print(Boolean.valueOf(str) ? "true" : "false");
    }
    public static void main(String args[]) {
        printB("tRuE");
        printB("false");
    }
}

A. truefalse
B. falsefalse
C. truetrue
D. falsetrue
E. Compilation Error or Runtime Error
Topic: Java Boolean Class

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.

E

Posted by Arul Palanisamy    2014-07-23 12:40:00


E; compilation error because boolean supports true and false(case sensitive) values

Posted by Bahunadam Narendra    2014-07-23 12:40:50


A;

Posted by Meghana Trikovala    2014-07-23 12:59:21


B

Posted by Gopinath Manchikanti    2014-07-23 13:30:25


e.since boolean supports true n false n input given is tRue False

Posted by Asma Mujtaba Khan    2014-07-23 14:13:24


A

Posted by Samyuktha Reddy    2014-07-23 14:20:37


A
Boolean is an object wrapper
Boolean.valueOf will return Boolean value represented by string
? : is like if else

Posted by Tushar Ghude    2014-07-23 14:30:09


A is the right answer...

Posted by Shubham Bansal    2014-07-23 18:26:24


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

Posted by Merit Campus    2014-07-24 04:49:24


© meritcampus 2019

All Rights Reserved.

Open In App