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
How do you compare objects in java?
What is an error in java?
Can we override the static method?
What are benefits of java?
What is the maximum size of list in java?
How do you replace all in word?
What is private public protected in java?
What is the advantage of functional interface in java 8?
can any body body expalin best definitions & best real time exaples for opps concepts.
Are private methods final?
What is an infinite loop?
What java is used for?
Is Constructor possible in abstract class in java ?
Is java based on c?
Explain java heap space and garbage collection?