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 the differences between heap and stack memory in java? Explain
What is the collections api in java programming?
What are abstract classes and anonymous classes?
What is the difference between quicksort & mergesort? When should they be used? What is their running time?
Where to store local variables?
Can keyword be used as identifier?
If I only change the return type, does the method become overloaded?
Explain the difference between call by refrence and call by value?
What is an immutable object?
Explain wait() method of object class ?
How do you print array in java?
What is a “stateless” protocol ?
What is parsing in java?
What is ellipsis in java?
What is n in java?