Engineering Full Stack Apps with Java and JavaScript
What is wrong with the following code written in a single file named TestClass.java?
class SomeThrowable extends Throwable { } class MyThrowable extends SomeThrowable { } public class TestClass{ public static void main(String args[]) throws SomeThrowable{ try{ m1(); }catch(SomeThrowable e){ throw e; }finally{ System.out.println("Done"); } } public static void m1() throws MyThrowable{ throw new MyThrowable(); } }
Select 2 options
A. The main declares that it throws SomeThrowable but throws MyThrowable.
B. You cannot have more than 2 classes in one file.
C. The catch block in the main method must declare that it catches MyThrowable rather than SomeThrowable.
D. There is nothing wrong with the code.
E. Done will be printed.