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
What are the different types of sorting in java?
Can set contain duplicates?
What are the topics in core java?
When a thread is executing a synchronized method , then is it possible for the same thread to access other synchronized methods of an object ?
Why is the main method static?
What is a boolean output?
Is it possible to define a method in java class but provide it’s implementation in the code of another language like c?
What is boolean data type in java?
Which variables are stored in stack?
How can you add and remove nodes in jtree?
What are inner classes or non static nested classes in java?
What are the drawbacks of reflection?
How many return statement are allowed in a function?
Differentiate between class and structure.
What are the advantages of java over cpp?