Java Programming and Technical Programming Technical

finally block will get executed whether or not an exception occurs. State True or False

Read Solution (Total 3)

Java Other Question

Which of the following statement(s) are not true?

A. For each try block there can be zero or more catch blocks but only one finally block
B. Finally block will get executed whether or not an exception occurs.
C. A try block must be followed only by at least one catch block
D. A try block has multiple catch block, then those exception handlers can be in any order
Observe the code.

public class Sample {

public static void main(String args[]) {

int i=10,j=0,k;

try {

k=i/j;

}

catch(Exception e) {

System.out.println("Exception");

}

catch(ArithmeticException e) {

System.out.println("Arithmetic exception");

}

}

}

Predict the output.

A. ArithmeticException
B. Compilation Fails
C. Exception
ArithmeticException
D. Runtime exception