What is the difference between throw and throws?

Answer Posted / manish kushwaha

First of all i would say both are reserved keyword in java

In Java Exception handling we are using above keyword throw
and throws.

Difference:
throws: throws clause is always use to propagate method
level exception, when ever you will use this clause, caller
method responsibility is to handle exception trowed by the
same method.

throw: this is the clause use to throw the instance of that
exception, main use of this throw clause is in user define
exception use you have written your own exception when ever
this exception will come you will throw this exception object.

Is This Answer Correct ?    1 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How many boolean functions are there?

507


What is array pointers ?

607


os is developed in c no java is more secured then c na why dont the os developed is developed using java

3527


What is the difference between delete and delete[]

586


What is the type of lambda expression?

542






What checkbox method allows you to tell if a checkbox is checked?

543


What is the purpose of the main method?

545


Can we execute a program without main?

541


Is 64bit faster than 32 bit?

584


What’s a deadlock?

612


Hi.... I applied for the post of scientific officer/Engineer-SB(Programmer).Please post the syllabus and sample papers.

1513


Can we clone singleton object?

567


What is the use of predicate in java 8?

495


Can private class be inherited in java?

553


What is append in java?

631