Which is the best way of exception handling?
Answer Posted / sudhir dhumal
First best way is use built-in exception classes wherever possible, you don't need to create your custom exception class to represent every scenario, so try to use existing exception classes
Second best way of handling exception is creating custom exception for specific scenario by extending our class with Exception class.
Consider the following example...
public class BookSearchException extends Exception {
public BookSearchException(String message) {
super(message);
}
}
Is This Answer Correct ? | 3 Yes | 0 No |
Post New Answer View All Answers
why Interface used?
What is bean? Where it can be used?
Why is it called boolean?
Which is illegal identifier in java?
Can you override a final method?
What does singleton mean in java?
What is keyword and identifier?
What is the difference between interface & abstract class?
Why we do exception handling in java and how many types of exceptions are there?
How do you convert boolean to boolean?
What does sprintf mean?
What is an eror in java?
What is the equal sign?
What is classname class in java?
Can we split string with in java?