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
Can java hashmap have duplicate keys?
What technique can be employed to compare two strings?
What does sprintf mean?
Is java call by value?
What are the advantages of java over cpp?
Is java 9 released?
what is the difference between Object Based Language and Object Oriented Language?
What is string in java? String is a data type?
What is singleton class in ruby?
Can you instantiate the math class in Java?
What is anti pattern in java?
Give an example of call be reference significance.
Explain 5 io best practices?
What are serialization and deserialization?
Why do we need strings in java?