what is difference between throw and throws in exception?
Answer Posted / balu
throws clause is used when the programmer does not want to handle the exception and throw it out of a method.
throw clause is used when the programmer wants to throw an exception explicitly and wants to handle it using catch block hence throw and throws are contradictory.
throw clause can be used to throw our own exceptions also i.e user-defined exceptions.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Explain the difference between an Interface and an Abstract class?
Implement two stacks using a single array.
Can an interface have a constructor?
Why inputstreamreader is used in java?
What is a generic data type?
What is the difference between JDK and JVM?
In Java list the methods that can be overridden?
Explain about core java?
Explain wait(), notify() and notifyall() methods of object class ?
Can java list be null?
What do you mean by chromounits in java8?
What is the += operator called?
How will you reverse a link list without using recursion?
String class is defined under which package in java?
What are the four pillars of java?