Consider the following code segment:
Boolean b = null; System.out.println(b ? true : false);
Which one of the following options correctly describes the behavior of this code segment?
b)
Note that unboxing can take place in expressions when you use a wrapper type object in place of a primitive type value.
In this case, in the condition check for the conditional operator (?: operator), a primitive boolean value is required, but a wrapper type object is provided.
Hence auto-unboxing occurs, with the reference pointing to null.
As a result, this code segment results in throwing a NullPointerException.