what is difference between throw and throws in exception?
Answer Posted / raju
throw : throw is used to throw user defined exceptions.
For ex: MyException written by user.it may be either
checked or unchecked exception.
throws: throws is used to throw exception those are handled by
JVM directly.
throws is used in method declaration to
intimate user that, it throw the exception that must
be handled by calling method.
Note :use throws when your method does not handle exception.
| Is This Answer Correct ? | 4 Yes | 1 No |
Post New Answer View All Answers
What is sorting algorithm in java?
What are checked exceptions?
What are data types in oop?
Is null or empty java?
What is split return?
Explain java heap space and garbage collection?
Are registers volatile?
Why call by value prevents parameter value change?
Differentiate between postfix and prefix operators in java.
Can we able to pass objects as an arguments in java?
Why does java not support pointers?
How to change the priority of thread or how to set priority of thread?
When can you say a graph to be a tree?
what is method reference in java 8?
Do we have pointers in java?