Java - Exception Handling - Interview Questions and Answers on throw and throws

Q1.   What is exception propogation ?

Ans. Passing the exception object to the calling method.

Q2.  Difference between throw and throws ?

Ans. throw is used to explicitly throw an exception especially custom exceptions, whereas throws is used to declare that the method can throw an exception.

We cannot throw multiple exceptions using throw statement but we can declare that a method can throw multiple exceptions using throws and comma separator.

Q3.  Explain throw, throws , try and catch in Java ?

Ans. throw is used to re throw an exception.

throws is used to declare that the method throws the respective exceptions.

try block is used to identify if the respective block has thrown any exception.

catch is used to catch the exception that has been thrown by the respective try block.