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
Explain when we should make an instance variable private.
What is Java Package and which package is imported by default?
How can you traverse a linked list in java?
Can you start a thread twice in Java?
Where is the find and replace?
What language is java written?
Does treeset allow null in java?
What is the use of java?
How to call one constructor from the other constructor ?
What is flush buffer?
What is field name?
Why do we need data structure in java?
What is runtime polymorphism or dynamic method dispatch?
What is the use of inner class?
What is a default constructor and also define copy contrucyor?