what is difference between throw and throws in exception?
Answer Posted / anu mathew
throws:
Method capable of raising an exception but not handling the
same. i.e to say no Try Catch block is implemented in the
Method, to handle the exception.
The callers should create the Try Catch Block to safeguard
against the exception.
If the above is not followed it would result in Compilation
errors.
throw:
The method that raises the exception also handles the same
in its Catch block.
If unhandled the exception can also be handles by the
Callers Try Catch Block.
Hope this makes sense.
| Is This Answer Correct ? | 44 Yes | 10 No |
Post New Answer View All Answers
What is a parameter in simple terms?
What is Java Package and which package is imported by default?
What is overriding in java?
Can a class declared as private be accessed outside it’s package?
Does java support function overloading, pointers, structures, unions or linked lists?
What are data structures in java?
Is class forname reflection?
What does substring mean?
What do you understand by soft reference?
In java, what is the difference between method overloading and method overriding?
What is the default size of arraylist in java?
Explain about sets?
Can you declare the main method as final?
Is object a data type?
Difference between vector and arraylist.