More than 3000 questions in repository. There are more than 900 unanswered questions. Click here and help us by providing the answer. Have a video suggestion. Click Correct / Improve and please let us know.
Ans. throw is used to re throw an exception.throws is used to declare that the method throws the respective exceptions.try block is used to identify if the respective block has thrown any exception.catch is used to catch the exception that has been thrown by the respective try block.
Help us improve. Please let us know the company, where you were asked this question :
Ans. When an exception is thrown within the body of a try statement, the catch clauses of the try statement are examined in the order in which they appear. The first catch clause that is capable of handling the exception is executed. The remaining catch clauses are ignored.
Help us improve. Please let us know the company, where you were asked this question :
a. try block followed by catch b. try block followed by finally c. try block followed by catch block and then finally d. try block without catch or finally block
Ans. try block without catch or finally block
Help us improve. Please let us know the company, where you were asked this question :
Ans. In first case the whole loop will terminate as soon as any exception happens in the method calculate ( assuming calculate method is not handling its exception and those are thrown back at the calling method )
In Second case exception will be caught for individual iteration and hence it wont break the loop and will continue for the next iteration.
Help us improve. Please let us know the company, where you were asked this question :