What is the output of the following Java program?
public class Main {
static int f() {
int x = 1;
try { return x; }
finally { x = 2; }
}
public static void main(String[] args) {
System.out.print(f());
}
}- A1
- B2
- C12
- DCompilation error
Correct answer: A