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
What is byte code and why is it important to java’s use for internet programming?
Can an unreferenced object be referenced again?
Explain the difference between abstract classes and interfaces in java?
What is the use of http-tunneling in rmi?
What are the types of web technologies?
What is the size of arraylist in java?
What is arrays sort in java?
What are the different types of inner classes?
What is an immutable class?
What is the method to declare member of a class static?
How does remove work in java?
What is the difference between reader/writer and inputstream/output stream?
Write code to implement bubble sort in java?
What is data type modifier?
What does string [] args mean?