Professional Documents
Culture Documents
1. Determine the output of the following code when the input is (a) –1, (b) 0, and (c) 12XY.
This is the same question as Exercise 1, but the code here has the finally clause.
try{
number = Integer.parseInt( JOptionPane.showInputDialog(null,
"input"));
if (number != 0) {
throw new Exception("Not Zero");
}
}
catch (NumberFormatException e) {
System.out.println("Cannot convert to int");
}
catch (Exception e) {
System.out.println("Error: " + e.getMessage());
}finally {
System.out.println("Finally Clause Executed");
}
2.
2. Determine the output of the following code.
import java.util.*;