Complete the questions below either in answer in a Word docu
Complete the questions below, either in answer in a Word document that you then attach, or by answering in the comments section.
In what ways might an exception be handled?
What happens if an exception is not caught?
When (under what conditions) does the catch block execute?
Look at the Java API for Exception and its subclasses. Name one example of an unchecked exception and a checked exception.
If a method throws an exception, how does it specify that exception?
Solution
Complete the questions below, either in answer in a Word document that you then attach, or by answering in the comments section.
In what ways might an exception be handled?
Exception can be handled by using try and catch blocks. Whenever Exception occurs in try block, then automatically catch block will catch the Exception that means execute the Exception. One try block has multiple catch blocks.
What happens if an exception is not caught?
In the Case of Exception is not caught that means the execution of program can be terminated and System displays a message that cannot be understand that means it is non user friendly message.
When (under what conditions) does the catch block execute?
In the Situation of when Exception occurs in try block, the catch block will execute the Exception. Particularly in the case of arithmetic Exception.
Look at the Java API for Exception and its subclasses. Name one example of an unchecked exception and a checked exception.
Checked Exception is ClassNotFoundException
Unchecked Exception is ArrayIndexOutofBoundsException
If a method throws an exception, how does it specify that exception?
Whenever throw statement in the function then the next statement will not execute. The control of the program moves catch block then check whether thrown Exception can be handled here or not.
Then it will check all the catch blocks which one is handled, No catch block not handled exception then it will be generate system generated Exception.
