What is difference between throw and throws ?

devquora
devquora

Posted On: Feb 22, 2018

 

Difference between throw and throws are:

ThrowThrows
It is basically used inside the function. It is used when it needs to insert the exception.It is basically present in the function signature. Here if the functions have the same statements then it can result in certain exceptions.
It is used to basically use the exception. It can throw only a single exception at ones.Here multiple exceptions can be thrown and then whichever matches are thrown automatically.
The exception which is been thrown cannot be checked here.Here for the propagation purpose, the throws can use the throw keyword. Here it can use the specific exception class.

    Related Questions

    Please Login or Register to leave a response.

    Related Questions

    Cyient Java developer Interview Questions

    List types of storage classes in java?

    There are basically four types of storage classes in Java:Automatic storage class: When a variable that is used in the coding is defined within a function and that also with the auto specifier the...