-
What is the output of this program?
public class Exec_Handling_Example
{
public static void main(String args[])
{
try
{
int k, n;
n = 5;
for (k = -2; k < 2 ;++k)
{
n = (n / k);
System.out.print(k);
}
}
catch(ArithmeticException e)
{
System.out.print("0");
}
}
}
-
- -1 0
- 0 -1
- 0
- 1
- None of these
Correct Option: A
For the 1st iteration -1 is displayed. The 2nd exception is caught in catch block and 0 is displayed.