Computer Science, asked by TbiaSamishta, 1 year ago

What is the use of throw and throws keyword ?

Answers

Answered by Secondman
0

"       In java, throw and throws keywords are both used for the purpose of exception handling. Before answering the question, first let us know about what exception handling is and what an exception is.

An exception is an unexpected event or condition that occur during the compiling time of the program and may lead to unexpected termination of the program.

      However, there’s a difference between the use of throws and throw keyword.

Throws keyword is generally used at the beginning of a block for handling the specified exception in that block whereas throw is used at the place (in try-catch block) where the programmer needs to throw the exception.

"

Similar questions