http://www.jiris.com/ mockexam 2 Question 27:
---------------------------------
import java.io.*;
public class Test027
{
public static void main(
String args[]) {
System.out.println(method());
}
static int method() {
try {
throw new IOException();
}
catch (IOException ioe) {
System.out.println("0");
return 0;
}
finally {
System.out.println("1");
return 1;
}
return 2;
}
}
------------------------------------
During compiling, error occurred with "unreachable statement, return 2". I thought new IOException was thrown in try block, then catch block caught it and returned "0". Apparently it did not work like that. Can any one explain this? Thank you very much!
Moya