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 does 0 mean in boolean?
How do you sort in ascending order in java?
What is the size of boolean variable?
What is function and method in java?
What is the concatenation operator in java?
What is the exact difference in between Unicast and Multicast object?
What is a singleton in genetics?
Why java is a platform independent? Explain
What is java thread dump, how can we get java thread dump of a program?
Can we clone singleton class in java?
How is treeset implemented in java?
What is nextline method in java?
What is the best definition for data?
What is class and its types?
What are use cases?