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 the tradeoff between using an unordered array versus an ordered array?
What is cr keyboard?
What is the difference between actual and formal parameters?
Why singleton class is used in java?
What is difference between static variable and global variable?
What is tcp and udp?
What are daemon Threads in java?
What is the formula to calculate percentage?
What are the two types of java?
What is jvm? Why is java called the platform independent programming language?
What is synchronization and why is it important in java programming?
What are static methods?
What is qualitative variable?
What is the largest number a double can hold?
Is empty set an element of empty set?