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 the different between get and post?
Can we overload the constructors?
Can java list be null?
How do you sort a list in java?
Explain the difference between comparator and comparable in java?
How many bits are used to represent unicode, ascii, utf-16, and utf-8 characters?
What is the difference between yielding and sleeping in java programming?
What is collection sort in java?
What do you mean by mnemonics?
What is a map in java?
Is it possible to override private or static method in java?
What is the difference between the Reader/Writer class hierarchy and the InputStream/OutputStream class hierarchy?
Write a program to print count of empty strings in java 8?
What are the restrictions imposed on method overriding?
What is the difference between this() and super() in java?