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 a double?
What is append in java?
What do you understand by the term string pool?
What is your platform?s default character encoding and how to know this?
How can you generate random numbers in java?
What do you understand by overloading and overriding in java?
What is the main functionality of the remote reference layer?
What is use of inner class in java?
What are synchronized methods and synchronized statements in java programming?
Define an enumeration?
Which java collection does not allow null?
What is the difference between applet and application?
when you will synchronize a piece of your code? : Java thread
Why is it called a string?
I want to re-reach and use an object once it has been garbage collected. How it's possible?