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

Can you sort a string in java?

918


What is null data type?

1111


Is overriding possible in java?

967


How do you sort arrays in java?

935


What is keyword auto for?

1191


Is minecraft 1.15 out?

981


Explain what pure virtual function is?

1029


How hashmap works in java?

1052


What is the memory leak in java?

1046


What is a functional interface?

1048


What will be the default values of all the elements of an array defined as an instance variable?

1034


Why vector is used in java?

1030


What is an immutable object?

1106


Can we create an object of static class in java?

1022


What is Mutex (Mutual Exclusion Object) ?

1155