Multiple choice technology programming languages

Why will the following code not compile? Boolean b = new Boolean("false"); if (b) {}

    1. The quotes should not be around false.
    1. New should be after Boolean.
    1. A boolean is expected not a Boolean.
    1. The Semi-colon should not be used.
Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

In Java, you cannot use a Boolean wrapper object directly in an if statement - the condition expects a primitive boolean. The Boolean object must be unboxed (either explicitly via booleanValue() or through auto-unboxing in some contexts). The code fails because 'if (b)' attempts to use the Boolean object as a boolean primitive.