+ 1
What is the output of this code? Why?
public class A{ public static void main(String arg[]) { A a=new A(); System.out.print(a.fun(0)); } public int fun(int x){ try { int y=50; return y/x; } finally { return 10; } } }
1 Answer
+ 9
ArithmeticException occurs in try block.- 50/0 . However, this program still generates 10 as output. finally block will always be executed.



