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 a bubble sort in java?
Explain thread in java?
What are java methods?
What exactly is java?
What are use cases?
How to perform quicksort in java?
Can we create object of inner class in java?
What are the advantages of exception handling?
What is the difference between a local variable and an instance variable?
Does java linked list allow duplicates?
Convert Binary tree to linked list.
Is Constructor possible in abstract class in java ?
Which language is java?
What is array in java?
Can we create our own wrapper class in java?