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 java virtual machine?
What is serial version uid and its importance in java?
Why we used vector class?
How can you say java is object oriented?
What are inbuilt functions in java?
Difference between Linked list and Queue?
What are synchronized methods and synchronized statements in java programming?
What is the final keyword in java?
What are the loops in java?
What is hashing principle in java?
What is the basic difference between string and stringbuffer object?
What is the difference between path and classpath variables?
Why is a singleton bad?
How do you escape a string?
What is meant by javabeans?