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 n = args.length;
    int n1 = 9 / n;
    System.out.print(n);
    try
    {
    if (n == 1)
    n = n / n - n;
    if (n == 2)
    {
    int s = {1};
    s[8] = 9;
    }
    }
    catch (ArrayIndexOutOfBoundException e)
    {
    System.out.println("Hello");
    }
    catch (ArithmeticException e)
    {
    System.out.println("Java");
    }
    }
    }
    }
    1. Runtime Error
    2. Compilation Error
    3. First
    4. Second
    5. None of these
Correct Option: B

Compilation Error

error: 'try' without 'catch', 'finally' or resource declarations
try
^
1 error



Your comments will be displayed only after manual approval.