Below is Enthuware question, answer, and explanation:
The following class will print '2' when compiled and run.
The answer is true, and below is the explanation
If the array reference expression produces null instead of a reference to an array, then a NullPointerException is thrown at runtime, but only after all parts of the array reference expression have been evaluated and only if these evaluations completed normally. The embedded assignment of 2 to index occurs before the check for a null pointer.
In an array access, the expression to the left of the brackets appears to be fully evaluated before any part of the expression within the brackets is evaluated.
Note that, if evaluation of the expression to the left of the brackets completes abruptly, no part of the expression within the brackets will appear to have been evaluated.
If I understand correctly
1. getArray() is evaluated first, but that returns a null. This doesn't mean the evaluation will end abruptly
2. [index=2] sets index to 2
3. ++ will make the operation end abruptly since getArray() points to a null