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
Is void a data type?
What is an array in java?
How do I stop concurrentmodificationexception?
What is data type modifier?
What is the same as procedures?
What is the purpose of object oriented programming?
What is the difference between error and an exception?
Difference between serialization and deserialization in java?
Can I import same package/class twice?
What will happen if there is a default method conflict as mentioned above and we have specified the same signature method in the base class instead of overriding in the existing class ?
What is a super method?
Are generics important java?
What are the advantages of defining packages in java?
Is ++ operator thread-safe in java?
Why string is a class?