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


Please Help Members By Posting Answers For Below Questions

How do you escape in java?

572


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

1070


What are the 5 types of research methods?

583


what methods would you overwrite in java.lang.object class?

560


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.

535






What are data types in programming?

546


What are inner classes or non static nested classes in java?

703


Why can't we make a class private in java?

532


What all methods are used to prevent thread execution ?

547


What is meant by structural programming?

549


What are passing parameters?

583


Can arraylist hold different types java?

482


Can a class extends itself in java?

527


Which package is always imported by default?

541


What is string pool in java?

559