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
Can private class be extended java?
Explain what access modifiers can be used for variables?
What are the types of java?
I have multiple constructors defined in a class. Is it possible to call a constructor from another constructor’s body?
What is a lambda expression ? What's its use ?
What are the steps that are followed when two computers connect through tcp?
What is an enumeration?
Can It is possible to synchronize the constructor of a Java Class?
What is Enum in Java?
What do you mean by constructor?
Can java object be locked down for exclusive use by a given thread?
Give example to differentiate between call by value and call by reference.
What is a numeric digit?
What is the difference between JDBC 1.0 and JDBC 2.0?
Is set ordered?