Difference between throw and throws

Difference between throw and throws

Slno throw throws
1- It is used to explicitly throw an exception. It is used to declare an exception.
2- It is followed by an instance. It is followed by class.
3- It is used within the method. It is used with the method signature.
4- You cannot throw multiple exceptions. You can declare multiple exceptions e.g. public void method()throws IOException, SQLException.
5- Checked exceptions can't be propagated with throw only. Checked exception can be propagated with throws.

Posted on by