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
Write a program to reverse array in place?
What is the common usage of serialization?
What's the base class of all exception classes?
What do you mean by platform independence of Java?
Why are arrays useful in java?
What is defined as false sharing in the context of multithreading?
What does function identity () do?
What is a bubble sort in java?
What is the map interface in java programming?
What java ide should I use?
How will you print number in reverse (descending) order in BST.
How the interruptible method gets implemented?
What is a java object and java application?
What is increment in java?
what do you understand by synchronization? : Java thread