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
Can we overload the methods by making them static?
what are the methods in object?
What is meant by vector class, dictionary class, hash table class, and property class?
What is character in data type?
What are the methods of object class ?
What is computer compiler?
What is the purpose of default constructor?
Name container classes in java programming?
Explain throw keyword in java?
What is the best way to findout the time/memory consuming process?
What is the this keyword?
What are advantages of using Java?s layout managers than windowing systems?
What is a memory leak in java?
What is output buffer?
Define jit compiler?