Mastering Java Exception Handling Quiz
3 Questions
3 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

Which of the following is NOT a checked exception in Java?

  • RuntimeException (correct)
  • ClassNotFoundException
  • SQLException
  • IOException
  • What will be the output of the following code snippet?

    try { int[] arr = new int[5]; System.out.println(arr[10]); } catch (ArrayIndexOutOfBoundsException e) { System.out.println("Array index out of bounds!"); }

  • 0
  • Array index out of bounds! (correct)
  • 10
  • Compiler error
  • Which of the following statements about exception handling in Java is correct?

  • The try block must always be followed by a catch or finally block.
  • The catch block can handle multiple types of exceptions. (correct)
  • The finally block is optional and can be omitted.
  • The throw keyword is used to create a new exception object.
  • More Like This

    Use Quizgecko on...
    Browser
    Browser