Home » JAVA Programming » Exceptions » Question
  1. What is the output of this program?
    public class ExceptionHandling_Example
    {
    public static void main(String args[])
    {
    try
    {
    int p = args.length;
    int q = 10 / p;
    System.out.print(p);
    try
    {
    if (p == 1)
    {
    p = p / p - p;
    }
    if (p == 2)
    {
    int r = {1};
    r[8] = 9;
    }
    }
    catch (ArrayIndexOutOfBoundException e)
    {
    System.out.println("TypeA");
    }
    catch (ArithmeticException e)
    {
    System.out.println("TypeB");
    }
    }
    }
    }
    1. Compilation Error
    2. Rutime Error
    3. TypeA
    4. TypeB
    5. None of these
Correct Option: A

Compilation Error



Your comments will be displayed only after manual approval.