what is difference between throw and throws in exception?
Answer Posted / siva y
Throw is used to explicitly raise a exception within the program, the statement would be throw new Exception(); throws clause is used to indicate the exceptions that are not handled by the method. It must specify this behavior so the callers of the method can guard against the exceptions.
Throws is specified in the method signature. If multiple exceptions are not handled, then they are separated by a comma. the statement would be as follows: public void doSomething() throws IOException,MyException{}
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is tcp ip in java?
What is the integer of 16?
Is null a value?
What is the purpose of the main method?
What about static nested classes in java?
Is it safe to install java on my computer?
What is the scope or life time of instance variables?
Explain what is encapsulation?
When would you use a static class?
Find the value of a specified element of the array arr[i] where 0 <= i <= n-1
What access modifiers can be used for class ?
Is char a method in java?
Explain java coding standards for constants?
Describe different states of a thread.
How to provide security in java