Examveda
Examveda

What will be the output of the following Java program?
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");
            }
    }
}

Note: Execution command line: $ java exception_handling one two

A. TypeA

B. TypeB

C. 0TypeA

D. 0TypeB

Answer: Option D


This Question Belongs to Java Program >> Interfaces And Abstract Classes

Join The Discussion

Related Questions on Interfaces and Abstract Classes

What is an interface in Java?

A. A contract specifying a set of methods that a class must implement

B. A class that cannot be instantiated

C. A class that contains only static methods

D. A subclass of the Object class