Given:
2. public class Main { 3. static String a = null; 4. static String s = ""; 5. public static void main(String[] args) { 6. try { //from ww w .j av a 2 s.c o m 7. a = args[0]; 8. System.out.print(a); 9. s += "t1 "; 10. } 11. catch (RuntimeException re) { s += "c1 "; } 12. finally { s += "f1 "; } 13. System.out.println(" " + s); 14. } 15.}
And two command-line invocations:
java Main java Main x
What is the result?
F is correct.
The first invocation throws an exception which is caught, then finally runs.
The second invocation throws no exception, but finally still runs.