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
How do you escape in java?
I am a fresher and know core java, c languge, html, css etc if I am illegible for any job then send it on my email tatranakshay276@gmail.com
What are the 5 types of research methods?
what methods would you overwrite in java.lang.object class?
A non-static inner class may have object instances that are associated with instances of the class’s outer class. A static inner class does not have any object instances.
What are data types in programming?
What are inner classes or non static nested classes in java?
Why can't we make a class private in java?
What all methods are used to prevent thread execution ?
What is meant by structural programming?
What are passing parameters?
Can arraylist hold different types java?
Can a class extends itself in java?
Which package is always imported by default?
What is string pool in java?