Now look here
in the first case
we have not written the return statement in the try block
This compiles very fine

let us see now why
first of all we will see what does it do if we do not write return statement in the try block
1. When we do not write return statement in the try block, the control is not going to get returned
through the try block
2. This means that the corresponding catch block or the finally block will execute and if the exception is not thrown then the catch block does not get executed and after finally block has run , as the exception is not thrown, the code following the finally block will get executed
3. so when you are considering that line j+="4" should be unreachable, it is not true
it wil be unreachable if we write the return statement in the try block
like this
what do we do here?
we wrote a return statement
now what does that mean?
even if the exception is thrown in the try block or not
return to the calling method BUT AFTER executing the finally block
here as we wrote the return statement in try block
the compiler knows for sure that in either case (exception is thrown or not thrown)
the control is going to the calling method after TRY and FINALLY block has executed and hence the code below the finally block is not getting reached
hence the compiler shows the error that
F:\Java\Javaranch problems>javac Test1.java
Test1.java:26: unreachable statement
j += "4"; // should be unrechable
^
1 error
hope this helps and makes better understanding
happy preparation
Sebastian I know you are going to get certified this time , you are the winner and you have powers from within
best luck friend
