Mcq On Java Exception

21. Which of these is a super class of all exceptional type classes?

A. String
B. RuntimeExceptions
C. Throwable
D. Cacheable

View Answer


22. Which of these class is related to all the exceptions that can be caught by using catch?

A. Error
B. Exception
C. RuntimeExecption
D. All of the mentioned

View Answer


23. Which of these class is related to all the exceptions that cannot be caught?

A. Error
B. Exception
C. RuntimeExecption
D. All of the mentioned

View Answer


24. Which of these handles the exception when no catch is used?

A. Default handler
B. finally
C. throw handler
D. Java run time system

View Answer


25. What exception thrown by parseInt() method?

A. ArithmeticException
B. ClassNotFoundException
C. NullPointerException
D. NumberFormatException

View Answer


26. What is the output of this program?

 class exception_handling
 {
  public static void main(String args[])
  {
   try
   {
    System.out.print("Hello" + " " + 1 / 0);
   }
   finally
   {
    System.out.print("World");
   }
  }
 }

A. Hello
B. World
C. Compilation Error
D. First Exception then World

View Answer

27. What is the output of this program?

 class exception_handling
 {
  public static void main(String args[])
  {
   try
   {
    int i, sum;
    sum = 10;
    for (i = -1; i < 3 ;++i)
    {
     sum = (sum / i);
     System.out.print(i);
    }
   }
   catch(ArithmeticException e)
   {
    System.out.print("0");
   }
  }
 }
A. -1
B. 0
C. -10
D. -101

View Answer


28. Which of these operator is used to generate an instance of an exception than can be thrown by using throw?

A. new
B. malloc
C. alloc
D. thrown

View Answer


29. Which of these keywords is used to by the calling function to guard against the exception that is thrown by called function?

A. try
B. throw
C. throws
D. catch

View Answer


30. What is the output of this program?

  class exception_handling
  {
    public static void main(String args[])
    {
     try
     {       System.out.print("A");
      throw new NullPointerException ("Hello");
     }
     catch(ArithmeticException e)
     {
      System.out.print("B");
     }
    }
    }
A. A
B. B
C. Hello
D. Runtime Exception

View Answer







Also check :


Discussion


* You must be logged in to add comment.