Discussion :: Exceptions - Pointing out the correct statements (Q.No.3)
|Sonam said: (Sep 5, 2012)|
|Whenever we call any method that is throwing any exception we have two options:
either surround the calling method with try-catch block or throws exception.
|Akash said: (Aug 1, 2014)|
|There is no main method so it is not compilable.|
|Anusha said: (Apr 17, 2015)|
|It compiled Successfully if we write the code either throws Exception or throws TestException in place of /*Point X/.
Because the runTest() throws an TestException it is subclass of Exception so when we call runTest() in any method that method /*(In which method we calling runTest())*/ also caught either TestException or Exception.
For compilation the compiler doesn't check for main method Run time only JVM checks for main method. So it is successfully compiled but not executed.
|Arfat said: (Aug 7, 2016)|
|Public void test() method belongs to ExceptionTest class which does not implement any interface so it's a regular method that does not throw any exception.|
Post your comments here:
Email : (optional)
» Your comments will be displayed only after manual approval.