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
How many types of flags are there?
What about features of local inner class?
What does microservices mean?
Which of the classes will have more memory allocated?
What is meant by inheritance and what are its advantages?
How are the elements of a gridbaglayout organized in java programming?
What is collection class in java?
How to make a non daemon thread as daemon?
Is 0 a prime number?
Can we declare register variable as global?
What is jagged array in java?
How can we create a synchronized collection from given collection?
Why java is considered dynamic?
How concurrent hashmap works?
What is string [] java?