Question: What is wrong with the following code? Select the one correct answer. (a) The main() method must declare that it throws B. (b) The finally
What is wrong with the following code?
![public class RQ6A20 { public static void main(String [] args) throws A](https://dsd5zvtm8ll6.cloudfront.net/images/question_images/1706/9/4/1/48365bddc2b8c9f71706941470269.jpg)
Select the one correct answer.
(a) The main() method must declare that it throws B.
(b) The finally clause must follow the catch clause in the main() method.
(c) The catch clause in the main() method must declare that it catches B rather than A.
(d) A single try block cannot be followed by both catch and finally clauses.
(e) The declaration of class A is illegal.
public class RQ6A20 { public static void main(String [] args) throws A { try { action(); } finally { System.out.println ("Done."); } catch (A e) { throw e; } public static void action () throws B { throw new B(); } class A extends Throwable {} class B extends A {}
Step by Step Solution
3.32 Rating (152 Votes )
There are 3 Steps involved in it
b The only thing that is wrong with ... View full answer
Get step-by-step solutions from verified subject matter experts
