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 numel matlab?
Write a java program to print fibonacci series?
Explain jvm, jre, and jdk?
What are the advantages of java over cpp?
What is balanced tree in java?
How do constructors use this() and super()?
What is api data?
How does arraylist work in java?
What is data member in java?
What is the method to expand and collapse nodes in a jtree?
What is thread pool in java with example?
Can classes declared using the abstract keyword cab be instantiated?
Can you access non static variable in static context?
Is vector thread safe in java?
What is class forname?