The IT Certification Resource Center

Featured Deal

Get CompTIA, Cisco, and Microsoft training courses free for a week.
Learn More ❯

Question 19:

What will happen when you attempt to compile and run the following code snippet?

Boolean b = new Boolean("TRUE");
    
    if(b.booleanValue())
    {
        System.out.println("Yes : " + b);
    }
    else
    {
        System.out.println("No : " + b);
    }

A. The code will not compile.
B. It will print - Yes : true
C. It will print - Yes : TRUE
D. It will print - No : false
E. It will print - No : FALSE

\n\nnew Boolean("TRUE") produces a Boolean object that represents true.
\n\nnew Boolean("anything") produces a Boolean object that represents false. \n\nThe internal toString() representation of this object produces the boolean value string in lower case, hence it prints "Yes : true" instead of "Yes : TRUE".' )">