//Assume inputFile references a Scanner object try {input = inputFile.nextInt();
ID: 3817000 • Letter: #
Question
//Assume inputFile references a Scanner object try {input = inputFile.nextInt();} finally {inputFile.close();} catch (inputMismatchException e)} System.out.print1n(e.getMessage());} When an exception is generated, it is said to have been ______. a. built b. thrown c. caught d. killed This is a section of code that gracefully responds to exceptions. a. exception generator b. exception manipulator c. exception handler d. exception monitor If your code does not handle an exception when it is thrown, it is dealt with by this. a. default exception handler b. the operating systemExplanation / Answer
ANSWERS:
15. The execution of try - finally - catch as listed in the program will throw up an error.
The try block is executed then catch is executed for the try and at last the finally block for that particular try is performed.The correct sequence will be try - catch - finally. Here in the listed code after try block finally will be executed and the catch block wont be ever executed.
The catch statement - system.out.println(e.getMessage()); in the given code will print the default error message for an exception but the catch code will never be reachable as finally block will be executed before catch.
16. When an exception is generated, it is said to have been thrown.
Exception is thrown when it occurs and it is caught when the control is transferred.Each exception belongs to Throwable class. Creation of the exception object at time of execution is referred to as throwing an exception.
17. This is a section of code that gracefully responds to exceptions - exception handler
Exception Handler is a code used in case a program's normal execution of instructions is broken due to some random unknown event. It will basically handle all the run time errors.
18. If your code does not handle an exceptionn when it is thrown it is dealt with by this. - Default Exception Handler
Default Exception Handler will take care to all the exceptions that were missed during the execution of the program. The biggest benefit of default exception handler is it can be overridden, each application can have a new default exception handler.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.