When try and catch block is used ?
Answers were Sorted based on User's Feedback
Answer / raghuveer
When chance of exception and not to terminate the
application
| Is This Answer Correct ? | 4 Yes | 0 No |
Answer / sujanya
we are useing the try/catch for handling the
exceptions ,and then we can able to read and understand
the exception easily.
| Is This Answer Correct ? | 2 Yes | 0 No |
Answer / ravikiran
try is used to enclose the code which is supposed to throw
an exception
catch is used to catch the exception which is raised with
in the try block
| Is This Answer Correct ? | 3 Yes | 1 No |
Answer / vivek
in order to over come an abnormal condition try and catch
block is used
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / anandh
Try and Catch block is used for Exception handling..
Try block is used for monitor the errors and using catch
block we can shows to users what type of Exception occurred
in our program ...see the following Example code it can be
useful..
class ExceptionExample
{
public static void main(String args[])
{
int d, a;
try
{
d = 0;
a = 42 / d;
System.out.println("This will not be printed.");
}
catch (ArithmeticException e)
{
System.out.println("Division by zero.");// Here shows
Exception to user
}
}
}
| Is This Answer Correct ? | 1 Yes | 1 No |
How OOPS concept is achieved in Java?
6 Answers Cognizant, JPMorgan Chase, Xavient,
jdbc drivers?
What is the difference between compile-time polymorphism and runtime polymorphism?
What are the steps that are followed when two computers connect through tcp?
What is a nested list?
What is the implementation of destroy method in java. Is it native or java code?
What are the main features of java?
What are the common problems you have faced while implementing Java?
When wait(), notify(), notifyall() methods are called does it releases the lock or holds the acquired lock?
What is the default initialized value of String type variable?
What is the difference between char and char *?
how tha garbage collector know that the object will be deleted? on which algorithm the garbage collector works? what is the working principle of garbage collector? How manay types of garbage collectors r there?