Try: Try is a keyword and a block comes under
Exception handling tasks. Between this block, we write the tricky codes or the
codes which may raise exception at runtime.
Catch: Catch is a keyword and a block. Which is
use to handle the exceptions raise due to the code in try block. There can be
multiple catch blocks with a single try block.
Finally: Finally is a keyword use to free the
resources after the execution of code, written in try and catch block. This is
the only block which will always execute, whether there is any exception or
not.
Throw: Throw is use to generate custom
exceptions, created by developer. We can generate both compile and runtime
exceptions both. In this case, declared methods will handle the exception
Throws: Throws keyword is use to define, what type of exception may occur while execution
of the method. The implementing
class will handle the exception.
No comments:
Post a Comment
Thank you for your comments.