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

What is object-oriented paradigm?

620


Explain about serializable interface in java?

586


What do you mean by garbage collection used in java?

581


Explain exception chaining in java?

611


What is procedure overloading?

1804






What do you mean by local class?

519


Is java owned by oracle?

528


Can a final method be overloaded?

512


Differentiate storage classes on the basis of their scope?

676


What is the difference between yield() and sleep()?

546


What do you mean by local variable and instance variable?

519


Can we nested try statements in java?

632


What is ide with example?

550


What are the special characters?

538


Why use string handling in Java?

583