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
what is method reference in java 8?
What is a buffer in java?
What is difference between string and new string?
What is native method in java?
How many arguments can a method have java?
Does java map allow duplicates?
Can a class be private in java?
what is the use of pojo (plain old java objects)? how it is interact with crystal reports? pls urgent
How does a for loop work java?
What Is Query Throttling in java?
Is java hashset ordered?
Are private methods final?
How many tetrahedral voids are there in bcc?
How do you define a parameter?
How do you add an element to a set in java?