0 votes
in JAVA by
What is the difference between throw and throws?

1 Answer

0 votes
by

Below are few of the differences between throw and throws block

Throw Block :

1) The throw keyword is used to throw an exception explicitly.

2) The checked exceptions cannot be propagated with throw only.

3) The throw keyword is followed by an instance.

4) The throw keyword is used within the method.

5) You cannot throw multiple exceptions.

Throws Block :

1) The throws keyword is used to declare an exception.

2) The checked exception can be propagated with throws

3) The throws keyword is followed by class.

4) The throws keyword is used with the method signature.

5) You can declare multiple exceptions, e.g., public void method()throws IOException, SQLException.

...