What is the difference between throw and throws?
Answer Posted / senthil nathan
throws: If a method is not capable of handling the raised
exception and it wants the caller of the method to
handle the exception means then the method uses the
"throws" keyword... The exception raised here is
of System Exception not User Exception...
throw: If the method is capable of handling the exception
by using try&catch block then this method uses the
"throw" keyword.. It is also used to raise our own
exception.
| Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
How long will it take to learn java?
What are the four integer types supported by java?
What are the new features in java 8? Explain
What do you mean by Hash Map and Hash Table?
How do you use substring in java?
What state does a thread enter when it terminates its processing in java programming?
Which types of exceptions are caught at compile time?
Can we compare two strings in java?
What is queue in java?
Does a function need a return?
What are exception handling keywords in java?
What is the difference between post and put?
What are passing parameters?
Explain the differences between abstraction and encapsulation?
Why java is a platform independent? Explain