Exceptions


  1. Which of the following operators is used to generate instance of an exception which can be thrown using throw?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    new operator is used to create instance of an exception. Exceptions may have parameter as a String or have no parameter.


  1. Which of the following keyword is used by calling function to handle exception thrown by called function?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    A method specifies behaviour of being capable of causing exception. Throws clause in the method declaration guards caller of the method from exception.



  1. Which of the following handles the exception when a catch is not used?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    Default handler is used to handle all the exceptions if catch is not used to handle exception. Finally is called in any case.


  1. Which part of code gets executed whether exception is caught or not?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    Finally block of the code gets executed regardless exception is caught or not. File close, database connection close, etc are usually done in finally.



  1. Which of the following should be true of the object thrown by a thrown statement?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    The throw statement should be assignable to the throwable type. Throwable is the super class of all exceptions.