Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

Explain the difference between extends thread vs implements runnable in java?

1061


Is binary a low level language?

871


What is compareto?

970


Can we declare a class as abstract without having any abstract method?

952


What do you mean by collectors in java 8?

886


How do constructors use this() and super()?

1051


Why is sizeof not a function?

942


What is use of super keyword?

917


Difference between static and dynamic class loading.

1052


How is abstraction implemented in java ?

921


What is the synonym of procedure?

1017


what is thread? What are the high-level thread states? Or what are the states associated in the thread? : Java thread

943


Is it possible to compare various strings with the help of == operator?

925


Can a class extend 2 classes in java?

983


What are the advantages of passing this into a method instead of the current class object itself?

1619