Examveda
Examveda

What will be the output of the following Java code?
class exception_handling 
{
    public static void main(String args[]) 
    {
        try 
        {
            int i, sum;
            sum = 10;
            for (i = -1; i < 3 ;++i) 
            {
                sum = (sum / i);
            System.out.print(i);
            }
        }
        catch(ArithmeticException e) 
        {     	
            System.out.print("0");
        }
    }
}

A. -1

B. 0

C. -10

D. -101

Answer: Option C


This Question Belongs to Java Program >> Exceptions

Join The Discussion

Related Questions on Exceptions