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
Is string is a data type in java?
What is the transient keyword?
What is the purpose of an interface?
Can we sort array in java?
What is the purpose of using the java bean?
why an outer class cannot be declared as private?
what r advatages of websphere? & how to deploy?
Is null an object in java?
What kind of variables a class can consist of?
What is the use of inner class?
What is private static class in java?
Can memory leak in java?
What does the ‘static’ keyword mean? Is it possible to override private or static method in java?
What java ide should I use?
Why do we use predicate in java?