Question: Java NetBeans project ***please show solution**** public class TestClass { public static void main(String[] args) throws A { try { f(); } finally { System.out.println(Done.);
Java NetBeans project ***please show solution****
public class TestClass {
public static void main(String[] args) throws A {
try {
f();
} finally {
System.out.println("Done.");
} catch (Exception1 e) {
throw e;
}
}
}
public class Exception1 extends Throwable{}
| Test Stem / Question | Choices |
| What is the problem with the above code? | A: The finally statement must be preceeded by the catch clause |
| B: Exceptions cannot be extended | |
| C: It is illegal to throw an exception | |
| D: Nothing is wrong | |
| What should be done with the code? | A: Move the catch clause before the finally clause. |
| B: Do not use Throwable as the supertype of Exception 1. | |
| C: Do not throw the exception. | |
| D: Nothing is wrong | |
| What happens after you have been able to fix the code? | A: Done is printed and an exception is shown in the stack |
| B: Done is printed | |
| C: Exception is shown in the stack | |
| D: Nothing is wrong |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
