【正确答案】参考程序
public class first_exception
{
public static void main (String args[])
{
char c;
int a,b=0;
int[] array=new int[7];
String s="Hello";
try
{
a=1/b;
}
catch(ArithmeticException ae)
{
System.out.println("Catch "+ae)) ;
}
try
{
array[8]=0;
}
catch (ArrayIndexOutOfBoundsException ai)
{
System.out.println(("Catch "+ai) ;
}
try
{
c=s.charAt(8)) ;
}
catch (StringIndexOutOfBoundsException se)
{
System.out.println(("Catch "+se) ;
}
}
}
【答案解析】