answersLogoWhite

0

When should we use exception handling in java?

Updated: 8/17/2019
User Avatar

Wiki User

14y ago

Best Answer

Exception handling should be used in Java in all cases where you as a programmer suspect that your code might throw some exceptions or create errors that might look ugly when a user is using the application. In such cases you use exception handling to catch and handle the exception and exit gracefully.

You use the try - catch block in Java for exception handling.

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: When should we use exception handling in java?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Does the Java exception mechanisms with try and catch clauses contribute to failure tolerance?

Yes, the purpose of the try-catch construct in Java is to help the system handle failure gracefully. Exception handling allows developers to detect errors easily without writing special code to test return values. Even better, it lets us keep exception-handling code cleanly separated from the exception-generating code. It also lets us use the same exception-handling code to deal with a range of possible exceptions.


Advantages of Exception handling in java?

Exception handling helps us catch or identify abnormal scenarios in our code and handle them appropriately instead of throwing up a random error on the front-end (User Interface) of the application. Exception handling allows developers to detect errors easily without writing special code to test return values. Even better, it lets us keep exception-handling code cleanly separated from the exception-generating code. It also lets us use the same exception-handling code to deal with a range of possible exceptions.


Why you handle exception in java?

Exception handling helps us catch or identify abnormal scenarios in our code and handle them appropriately instead of throwing up a random error on the front-end (User Interface) of the application. Exception handling allows developers to detect errors easily without writing special code to test return values. Even better, it lets us keep exception-handling code cleanly separated from the exception-generating code. It also lets us use the same exception-handling code to deal with a range of possible exceptions


Why you uses exception handling because you can handle exception using if Else statement?

We use exception handling so that the program can gracefully handle any situation that may be unexpected. We use try-catch for exception handling. if-else is a conditional logic checking mechanism


Why use catch keyword in java?

no, because catch is used to handle exceptions which are generated from try block


Why would you want to use user defined exception handling?

sometimes there are situations where the program is vary long which can make error debugging a long process so java provides a facility to make user defined exception handling suppose we are dividing two numbers a/b and if the user enters the value of b 0, the user wants to display an error of your own so the user can do this by using exception handling


How exception handling mechanism can be used for debugging a program in java?

Trapping and handling of runtime errors is one of the most crucial taska ahead of any programmer. AS A DEVELOPER, YOU SOMETIMES SEEM TO SPEND MORE TIME CHECKING FOR ERRORS AND HANDLING THEM THEN YOU DO ON THE CORE LOGIC OF THE ACTUAL PROGRAM.


Why should throw keyword is used in java?

Use it when you are implementing something that says it throws a certain exception when a certain condition is met.


What is NoSuchMethodFound Exception in java?

It means that you have tried to use a method which doesn't exist.


What is the use of catch block in java?

the catch block catches the exception from the try block to display a proper message about the exception. Answered by, SOORAJ.M.S


How you use java?

Hi You should read Java API , there is every thing that you need.


What is the current version of JDK?

As of February 2, 2012 the latest public release of the standard edition of Java is Java Standard Edition(SE) 7 update 3.