enter code here
`class Rethrow
{
public static void genException()
{
int n[]={4,8,16,32,64,128};
int d[]={2,0,8,0,4};
for(int i=0;i<n.length;i++)
{
try{
System.out.println("n/d is:"+n[i]/d[i]);
}
catch(ArithmeticException exc)
{
System.out.println("Cant Divide By Zero");
throw exc;
}
catch(ArrayIndexOutOfBoundsException exc)
{
System.out.println("No match element found ");
// rethrow the exception
}
}
}
}
class RethrowDemo
{
public static void main(String args[])
{
try
{
Rethrow.genException();
}
catch(ArithmeticException exc) // catch the rethrow Exception
{
// recatch exception
System.out.println("Fatal Error "+"Program Termiated.");
}
}
}
Question 1::why does catch of "RethrowDemo" CLASS terminate an exception thrown by catch(Arithmetic Exception) of "Rethrow" class.
Question 2:: how does transfer of control working ??