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


Please Help Members By Posting Answers For Below Questions

What is a double?

697


What is append in java?

733


What do you understand by the term string pool?

646


What is your platform?s default character encoding and how to know this?

1833


How can you generate random numbers in java?

671






What do you understand by overloading and overriding in java?

638


What is the main functionality of the remote reference layer?

1515


What is use of inner class in java?

622


What are synchronized methods and synchronized statements in java programming?

663


Define an enumeration?

707


Which java collection does not allow null?

811


What is the difference between applet and application?

623


when you will synchronize a piece of your code? : Java thread

632


Why is it called a string?

650


I want to re-reach and use an object once it has been garbage collected. How it's possible?

659