Refer Short Circuit operators (| | ,&&),in these operators ,decision to execute the second expression is based on the result of the first one.
Normal operators (&,|)will evaluate both the expressions.
At line 2, s.length() is evaluated and results in exception.
At line 4,s.length() is not evaluated because the first one is false.
At line 6,s.length() is evaluated as the first expression is false.
At line 8,s.length() is evaluated.