123456789101112131415



Question 1: class A{
public static void parse(String str) {
try {
float f = Float.parseFloat(str);
} catch (NumberFormatException nfe) {
f = 0;
} finally {
System.out.println(f);
}
}
public static void main(String[] args) {
parse("invalid");
}
}

What is the result?

1. 0.0
2. Compilation fails.
3. A ParseException is thrown by the parse method at runtime.
4. A NumberFormatException is thrown by the parse method at runtime.