Difference between throw and throws in Java

It is one of the impor­tant ques­tions in the inter­view room. There are numer­ous dif­fer­ence between throw and throws key­words. A list of dif­fer­ences between throw and throws are giv­en under­neath :

1)The main objec­tive of throw key­word is to cre­ate excep­tion object and han­dover to JVM, Some­times pro­gram­mer cre­ates excep­tion object pro­gram­mat­i­cal­ly and han­dover it to JVM for that throw key­word is required.Java throws key­word is used to declare an excep­tion. Used for a dec­la­ra­tion of excep­tion which indi­cates the excep­tion is thrown by a method.
2)Checked excep­tion can­not be prop­a­gat­ed using throw only.Checked excep­tion can be prop­a­gat­ed with throws.
3)Throw is fol­lowed by an instance.

throw new ArithmeticException(“Arithmetic Excep­tion”);

Throws is fol­lowed by class.

throws Arith­meticEx­cep­tion ;

4)Throw is used with­in the method to throw an excep­tion.

void m1() {
try {
/​/​throwing arith­metic excep­tion using throw
throw new ArithmeticException(“Number is not divi­sivle by 0!!”);
catch (Excep­tion exp) {
System.out.println(“Error : “+exp.getMessage());

Throws are used with the method sig­na­ture to declare an excep­tion.

/​/​Declaring arith­metic excep­tion using throws void m2() throws Arith­meticEx­cep­tion{ /​/​Statements }

5)You can­not throw mul­ti­ple excep­tions.

void m1() { /​/​Throwing sin­gle excep­tion using throw throw new Arith­meticEx­cep­tion(“An inte­ger should not be divid­ed by zero!!”); }

You can declare mul­ti­ple excep­tions e.g.

/​/​Declaring mul­ti­ple excep­tions using throws void m2() throws Arith­meticEx­cep­tion, Null­Point­erEx­cep­tion{ /​/​Statements where excep­tion might occur }

6)throw key­word is used to throw user defined excep­tion /​cus­tomized excep­tion.throws key­word is used to report the cus­tomized excep­tion.

Throw -

Throws -