Mcq On Java Exception

31. What is the output of this program?

 public class San
 {
  public static void main(String[] args)
  {
   try
   {
    return;
   }
   finally
   {
    System.out.println( "Finally" );
   }
  }
 }

A. Finally
B. Compilation fails
C. The code runs with no output
D. An exception is thrown at runtime

View Answer


32. A single try block must be followed by which of these?

A. finally
B. catch
C. finally & catch
D. none of the mentioned

View Answer


33.Which of these exceptions handles the divide by zero error?

A. ArithmeticException
B. MathException
C. IllegalAccessException
D. IllegarException

View Answer


34.Which of these exceptions will occur if we try to access the index of an array beyond its length?

A. ArithmeticException
B. ArrayException
C. ArrayIndexException
D. ArrayIndexOutOfBoundsException

View Answer


35. What is the output of this program?

 class exception_handling
 {
  public static void main(String args[])
  {
   try
   {
    int a = args.length;
    int b = 10 / a;
    System.out.print(a);
   }
   catch (ArithmeticException e)
   {
    System.out.println("1");
   }
  }
 }

A. 0
B. 1
C. Compilation Error
D. Runtime Error

View Answer







Also check :


Discussion


* You must be logged in to add comment.