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 jpa specification?
Which language is java?
What does business logic mean?
Can a variable be local and static at the same time?
Are generics important java?
Which class is the superclass of all classes?
Explain about fail safe iterators in java?
What is method in java with example?
Define the term string pool?
What is navigable map in java?
What is the diffrence between inner class and nested class?
Which data type is class in java?
Why deletion in linkedlist is fast than arraylist?
How many types of parsers are there?
Can we override constructors in java?