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
What is substring in java?
make a method which any number and any type of argument and print sum of that arguments.....
Why do we need hashset in java?
What is the use of flag?
Can we write a class without main method in java?
Is jdk required on each machine to run a java program?
Can java object be locked down for exclusive use by a given thread?
What is t type java?
Difference between ‘is-a’ and ‘has-a’ relationship in java?
Explain the difference between transient and volatile in java?
What is a list in java?
What about static nested classes in java?
What is unmodifiable list in java?
Is object a data type?
What is bifunction in java?