Examveda
Examveda

What will be the output of the following Java code?
class exception_handling 
{
    public static void main(String args[]) 
    {
        try 
        {
            int a = args.length;
            int b = 10 / a;
            System.out.print(a);
            try 
            {
                if (a == 1)
                    a = a / a - a;
                if (a == 2) 
                {
                    int []c = {1};
                    c[8] = 9;
                }
            }
            catch (ArrayIndexOutOfBoundException e) 
            {
                System.out.println("TypeA");
            }
            catch (ArithmeticException e) 
            {
                System.out.println("TypeB");
            }
        }
    }
}

A. TypeA

B. TypeB

C. Compile Time Error

D. 0TypeB

Answer: Option C


This Question Belongs to Java Program >> Exceptions

Join The Discussion

Related Questions on Exceptions