The issue is that your print statement is evaluated as:
System.out.println(("Result is: " + names) == null ? null : names.size());
This is due to the fact that + has more precedence than ?: operator So, as the string - "Result is null" is not equal to null, evaluating names.size() throws NPE.
Note that, when null is used in string concatenation, it is automatically converted to "null". So, "Result is: " + null will not throw NPE. This is as per JLS - String Conversion:
If the reference is null, it is converted to the string "null" (four ASCII characters n, u, l, l).
To fix the issue, you should add parenthesis around your conditional expression to enforce greater precendence to it:
System.out.println("Result is: " + (names == null ? null : names.size()));
0: names.size()