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 ststic with example
Can we have this () and super () together?
Can a class extends itself in java?
Why declare Main() inside the class in java ?
what is deadlock? : Java thread
How hashmap works in java?
Tell me a few examples of final classes defined in Java API?
What’s the difference between unit, integration and functional testing?
Using callable statement how can you pass out parameters, explain with example?
when should you use stringbuilder class in a program?
Can we catch more than one exception in single catch block?
How can you share data between two thread in Java?
What is a boolean expression in java?
Why do we need wrapper classes?
What is final method?