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
Implement 2 stacks with just 1 array. The stack routines must not indicate overflow unless every slot in array is used.
What is the difference between method and means?
What are the steps involved to create a bean?
What flag up means?
What are the loops in java?
What are the restrictions imposed by a Security Manager on Applets?.
What is r in java?
What is meant by final class?
Name component subclasses that support painting in java programming?
what are different ways in which a thread can enter the waiting state? : Java thread
What is the parse method in java?
Can we force garbage collector to run ?
How would you dynamically allocate memory to an array?
How an object is serialized in java?
How are java objects passed to a method and what are native methods?