Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

What are the different ways to handle exceptions?

The two methods to handle exception are as follows:-

Wrapping the desired code in the try block that is followed by catch block
List out the desired exception in throw and the caller of the method handle the exception

There are two ways to handle exceptions,
1. By wrapping the desired code in a try block followed by a catch block to catch the exceptions. and
2. List the desired exceptions in the throws clause of the method and let the caller of the method hadle those exceptions.

Best Teeth Whitening in Delhi | Cosmetic Dental Treatment in Delhi

There are three ways to handle exception.
1. Try catch block
2. Throws clause, that you define with method name
3. Throw clause that is thrown from the program to, raise an error condition in program.

We can provide multiple exceptions in the throws clause and it can be used with main() method also. try-catch – We use try-catch block for exception handling in our code. try is the start of the block and catch is at the end of try block to handle the exceptions.

Possibly Related Threads...
Thread / Author Replies Views Last Post

Forum Jump:

Users browsing this thread: 1 Guest(s)