SOURCE CODE:
Exception.java
public class Exception
{
public static void main(String args[])
{
int a[]={5,10};
int b=5;
try
{
int x;
x=a[2]/a[1];
}
catch(ArithmeticException e)
{
System.out.println("Division by zero");
}
catch(ArrayIndexOutOfBoundsException e)
{
System.out.println("Array Index Error");
}
catch(ArrayStoreException e)
{
System.out.println("Wrong data type");
}
int y=a[1]/a[0];
System.out.println("y = "+y);
}
}
OUTPUT :
Array Index Error
y = 2
EmoticonEmoticon