ExamVeda
Login
Home
This question belongs to Java Program Exceptions
Exceptions
?

What will be the result of executing the following code?
public class Test{
      public void divide(int a, int b){
            try{
	          int c = a / b;
   	    }catch(Exception e){
	          System.out.print("Exception ");
  	    }finally{
	          System.out.println("Finally");
      }

      public static void main(String args[]){
            Test t = new Test();
            t.divide(0,3);
      }
}

Answer & Solution
Correct Answer: Option D

Finally blocks are always executed whether exception occurs or not.
0/3 = 0 Does not throws exception.

Examveda
Question posted by Examveda
Community

Join the Discussion

1 Comment
Solomon Alamrew
Solomon Alamrew 10 years ago
the answer mus be 0 finally