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 concurrent hashmap and its features?
What is exception in java?
Write a function for palindrome and factorial and explain?
How do you remove an object from an arraylist in java?
I want to persist data of objects for later use. What is the best approach to do so?
Explain about field hiding in java?
What is a dot notation?
Write a function to print Fibonacci series and Tribonacci series?
What type of value does sizeof return?
What does index mean in java?
What is java regex?
When can you say a graph to be a tree?
What is casting in java programming?
Differentiate between array list and vector in java.
What is the difference between sop and work instruction?