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 are namespaces in java?
What is java jit compilers?
What do you mean by composition in java?
Write a program to print count of empty strings in java 8?
What is string pool?
Can a abstract class be defined without any abstract methods?
What is the difference between an object-oriented programming language and object-based programming language?
What is a locale?
Can an interface extend another interface?
What is the difference between a synchronized method and a synchronized block?
What is meant by object?
What is an anonymous class in java?
How do you use parseint in java?
What is thread safe in java?
What is the nested interface?