what difference between throw and throws in exception
handling.
Answer Posted / aravinda reddy
Whenever we want to force an exception then we use throw
keyword,throw keyword can also be used to pass a custom
message to the exception handling module i.e. the message
which we want to be printed. throw we will use at statement
level.
Whereas when we know that a particular exception may be
thrown or to pass a possible exception then we use throws
keyword. Point to note here is that the Java compiler very
well knows about the exceptions thrown by some methods so
it insists us to handle them. Method Level
| Is This Answer Correct ? | 0 Yes | 1 No |
Post New Answer View All Answers
What is a boolean used for?
What does opcode mean?
How we can skip finally block of exception even if some exception occurs in the exception block in java?
What is the latest version of java?
Why is a constant variable important?
What is a consumer in java?
Can we have try block without catch block?
Explain about member inner classes?
When super keyword is used?
What exceptions occur during serialization?
What is command line argument in java?
Is static a keyword in java?
how do I create a runnable with inheritance? : Java thread
What is multithreading and its advantages?
What do you mean by light weight and heavy weight components?