what is difference between throw and throws in exception?
Answer Posted / raju
throw : throw is used to throw exception by user whenever he
feels to throw exceptions. throw is used to throw
either user defined or runtime exception.
for ex : throw new MyException(), here MyException
is user written exception.
throw new NullPointerException(), here
NullPointerException is RuntimeException.
throws: throws is used by the method to throw exception to
the calling method. And method itself does not able
to handle it so it throws to calling method.
| Is This Answer Correct ? | 10 Yes | 0 No |
Post New Answer View All Answers
Is string is a keyword in java?
How can you handle java exceptions?
What is the common usage of serialization? What exceptions occur during serialization?
What is time complexity algorithm?
Is it possible for yielded thread to get chance for its execution again ?
What are multiple inheritances? Is it supported by java?
How do you check if an arraylist is not empty?
What are the advantages of autoboxing?
How many bits is a 64 bit byte?
What does null mean in java?
How do you clear a list in java?
What are classloaders?
What is space character in java?
What is qms certification?
What is the use of join method?