why there are multiple catches for a try block.don't tell me
that there can be multiple exception of a code segment
that's why.tell me the real fact behind this.
Answer Posted / tulasi prasad
I under stood ur problem, I will expalin with an example
public class Test
{
public static void main(String args[])
{
try
{
int n =2/args.length;
int x[]={1,2};
x[30]=4;
}
catch(ArithmeticException e)
{
System.out.println("Divede by Zero");
}
catch(IndexOutOfBoundsException e)
{
System.out.println("ArrayIndex Out of
Bounds");
}
}
}
if u run with out any commandline argument then u got
divide by zero exception. otherwise u get indexbounds
exception
| Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
Why do we need singleton?
what state does a thread enter when it terminates its processing? : Java thread
In the below example, what will be the output?
What is exception handling in java?
What are constructors in java?
What is java english?
What does exp mean in math?
Explain the difference between comparator and comparable in java?
List types of storage classes in java?
What is static variable with example?
What is wrapper class example?
What is lifetime variable?
How do I convert a numeric ip address like 192.18.97.39 into a hostname like java.sun.com?
Using callable statement how can you pass out parameters, explain with example?
Is a case study a method or methodology?