Answer Posted / 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 |
Post New Answer View All Answers
What is gui programming?
Why there are some null interface in java? What does it mean?
Can we have try block without catch block?
What is arguments in java?
List some oops concepts in java?
What are the states of thread in java?
Why is boolean important?
Give me example of derived data types.
What is the final field modifier?
Why a dead thread occurs?
How to Sort Strings which are given in List and display in ascending order without using java api.
Can an anonymous class be declared as implementing an interface and extending a class in java programming?
what is difference betweem home interface and remote interface?
What is collection sort in java?
give an example for encapsulation?