What is the output of the following code?
Integer i = null; if (i != null & i.intValue() == 5) System.out.println("Value is 5");
B.
The & operator does not short circuit.
Even though the left-hand operand is null, the right-hand operand is still evaluated.
Attempting to call the intValue()
method on null results in a NullPointerException.