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
Can an interface be defined inside a class?
What are the differences between heap and stack memory?
What is reflexive association?
What are the basic concepts of OOPS in java?
Are generics important java?
What is difference between throw and throws ?
What do you mean by data type?
How will you add panel to a frame?
What about method local inner classes or local inner classes in java?
How does varargs work in java?
What is not thread safe?
What is set in java?
How to sort numbers in java without array?
What are the different types of inner classes?
How is string immutable in java?