Java Exception Handiling

25 Questions

Settings
Please wait...
Java Quizzes & Trivia

ANSWER THE FOLLOWING QUESTIONS.


Questions and Answers
  • 1. 
    Pick runtime exception?....
    • A. 

      Class cast exception

    • B. 

      File not found exception

    • C. 

      Nullpointer exception

    • D. 

      Security exception

    • E. 

      Above all

  • 2. 
    Say true or false.The following program will compile: try { // do risky IO things } catch (IOException ioe) { // handle general IOExceptions } catch (IOException ioe) { // handle general IOExceptions }
    • A. 

      True

    • B. 

      False

  • 3. 
    Output of the following program try { x.doStuff(); } int y = 50; } catch(FooException fe) { }
    • A. 

      Compile without any error

    • B. 

      Runtime error

    • C. 

      Compile time error

    • D. 

      None of the above

  • 4. 
    A try with finally without catch can declare the exception
    • A. 

      True

    • B. 

      False

  • 5. 
    • A. 

      The ‘try’ block should be followed by a ‘catch’ block.

    • B. 

      The ‘try’ block should be followed by a ‘finally’ block.

    • C. 

      The ‘try’ block should be followed by either a ‘catch’ block or a ‘finally’ block.

    • D. 

      The ‘try’ block should be followed by at least two ‘catch’ blocks. The ‘try’ block should be followed by at least two ‘catch’ blocks.

  • 6. 
    Parent of Error is.......
    • A. 

      Object

    • B. 

      Collections

    • C. 

      Throwable

    • D. 

      Exception

  • 7. 
    If you throw an exception in your code, then you must declare it using the throws keyword in your method declaration.
    • A. 

      True

    • B. 

      False

  • 8. 
    The subclass exception should precede the base class exception when used within the catch clause.
    • A. 

      True

    • B. 

      False

  • 9. 
    The statements following the throw keyword in a program are not executed.
    • A. 

      True

    • B. 

      False

  • 10. 
    Exceptions can be caught or rethrown to a calling method.
    • A. 

      True

    • B. 

      False

  • 11. 
    Checked exceptions include all subtypes of Exception, including classes that extend RuntimeException.
    • A. 

      True

    • B. 

      False

  • 12. 
    File Not Found Exception class has descendants
    • A. 

      True

    • B. 

      False

  • 13. 
    In Java, exceptions are divided into two categories, namely checked and unchecked exceptions.
    • A. 

      True

    • B. 

      False

  • 14. 
    All subclasses of the RuntimeException and Error classes are unchecked exceptions.
    • A. 

      True

    • B. 

      False

  • 15. 
    When reading or writing a file it throws class not found exception
    • A. 

      True

    • B. 

      False

  • 16. 
    • A. 

      a-2,b-1,c-3,d-4

    • B. 

      A-4,b-3,b-2,c-1

    • C. 

      A-3,b-1,c-4,d-2

    • D. 

      A-1,b-2.c-3.d-4

  • 17. 
    What are checked exceptions
    • A. 

      Checked by java compiler

    • B. 

      Checked by java virtual machine

    • C. 

      Above two

    • D. 

      None of the above

  • 18. 
    What are un checked exceptions
    • A. 

      Checked by java compiler

    • B. 

      Checked by java virtual machine

    • C. 

      Above two

    • D. 

      None of the above

  • 19. 
    What is throws in exception
    • A. 

      A programmer can handle

    • B. 

      A programmer can not handle

    • C. 

      It handled by jvm

    • D. 

      None of the above

  • 20. 
    • A. 

      True

    • B. 

      False

  • 21. 
    Is it possible to re-throw exceptions
    • A. 

      True

    • B. 

      False

  • 22. 
    Creating an exception object and handling it to the run time system is called
    • A. 

      Exception handler

    • B. 

      Catch the exception

    • C. 

      Pass the exception

    • D. 

      Throwing an exception

  • 23. 
    Finally block will get invoke whether the exception is thrown or not
    • A. 

      True

    • B. 

      False

  • 24. 
    • A. 

      Skip the errors in program

    • B. 

      Propagating errors up the call stack

    • C. 

      Make the program to run

    • D. 

      Grouping & diff error type

    • E. 

      Separating error handling code from regular business logic code

  • 25. 
     exception is available in util package
    • A. 

      True

    • B. 

      False