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 condition in java?
In a container there are 5 components. I want to display all the component names, how will you do that?
What are the main concepts of oops in java?
What are the Main functions of Java?
What are the different types of garbage collectors in java?
What is another word for methodology?
What is anagram number?
Can an interface extend another interface?
How do you compare characters in java?
What is diamond operator in java?
What are heap memory and stack memory and what are memory tables.
What are loops in java?
How many characters is 2 bytes?
Is class is a data type?
What is functional interface in java example?