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 local class in java?
What is character in data type?
What is final access modifier in java?
Why do we need hashset in java?
What does escaping a character mean?
What is the meaning of nullable?
How to run a JAR file through command prompt?
Why is string buffer better than string ?
In Java list the methods that can be overridden?
What is a native method in java programming?
what is object slice?
Describe 2 different ways to concatenate two strings.
How do you square a number in java?
How does split work in java?
What are some examples of variable costs?