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
What is skeleton and stub?
Does constructor return any value?
What is the base class of all exception classes?
What is the purpose of the runtime class in java programming?
What is the method in java?
What does provide mean construction?
Explain where variables are created in memory?
Difference between default and protected access specifiers?
Difference between object and reference?
Explain about instanceof operator in java?
What is a null check?
What is included in core java?
Is java platform independent?
Is char a method in java?
What is the importance of static variable?