Exceptions


  1. Which of these packages contain all the Java’s built in exceptions?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    java.util


  1. Which of these exceptions will be thrown if we use null reference for an arithmetic operation?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    If we use null reference anywhere in the code where the value stored in that reference is used then NullPointerException occurs.



  1. Which of these class is used to create user defined exception?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    Exception class contains all the methods necessary for defining an exception. The class contains the Throwable class.


  1. What is the output of this program?
    public class exception_Example 
    {
    public static void main(String args[])
    {
    try
    {
    int array[] = {1, 2,3 , 4, 5};
    for (int k = 0; k < 7; ++k)
    System.out.print(array[k]);
    }
    catch(ArrayIndexOutOfBoundsException e)
    {
    System.out.print("5");
    }
    }
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    When array index goes out of bound then ArrayIndexOutOfBoundsException exception is thrown by the system.



  1. Which of these classes is used to define exceptions?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    Exception