Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
4 views
in Java by (6.5k points)
How is exception handling implemented using 'throws'?

1 Answer

0 votes
by (11.3k points)

When you have to specifically indicate that a particular method or function might have to throw mentioned exceptions, you use the throws keyword after the definition of your function. If somebody is calling such a function, that person will have to handle the specified exceptions using the try and catch blocks. If you're looking to learn java, below is the proper syntax for the same:

1

2

3

4

return_type method_name(parameter_list) throws exception_list

{

     //your code

}

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Feb 20, 2020 in Java by angadmishra (6.5k points)

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...