LearnFrenzy
Sign in Take a free test

Exception Handling · Exercise 1 of 4

Exception Handling Exception Handling MCQ

  • 20 questions
  • Page 1 of 2
  • Answers explained
0Attempted
0Correct
0Wrong
Directions

Twenty multiple-choice questions on Java exception handling: the hierarchy, checked and unchecked exceptions, try/catch/finally, multi-catch, throw and throws, custom exceptions, try-with-resources and assertions. Pick an option to check your answer instantly.

Question 1 Easy

Which class is the superclass of all exceptions and errors?

A Exception
B Throwable
C Error
D RuntimeException
Question page & discussion
Question 2 Easy

Which of these is a checked exception?

A NullPointerException
B IOException
C ArithmeticException
D IllegalArgumentException
Question page & discussion
Question 3 Easy

What must a method do with a checked exception that its code can throw?

A Nothing
B Catch it or declare it with throws
C Convert it to an Error
D Log it
Question page & discussion
Question 4 Easy

Which is an Error rather than an Exception?

A FileNotFoundException
B StackOverflowError
C NumberFormatException
D InterruptedException
Question page & discussion
Question 5 Easy

Which statement is correct?

A throws raises an exception
B throw raises an exception object; throws declares exceptions in a method signature
C Both are the same
D throw is used only in catch blocks
Question page & discussion
Question 6 Easy

When does a finally block run?

A Only if an exception is thrown
B Whether or not an exception is thrown, including after a return in try
C Only if no exception is thrown
D Only when catch runs
Question page & discussion
Question 7 Medium

What happens to finally if try calls System.exit(0)?

A finally runs first
B finally does not run – the JVM shuts down
C Compile error
D An exception is thrown
Question page & discussion
Question 8 Medium

In which order should catch blocks for FileNotFoundException, IOException and Exception appear?

A Exception, IOException, FileNotFoundException
B FileNotFoundException, IOException, Exception
C Any order
D IOException, Exception, FileNotFoundException
Question page & discussion
Question 9 Medium

Which multi-catch is legal?

A catch (IOException | FileNotFoundException e)
B catch (NumberFormatException | ArithmeticException e)
C catch (Exception | RuntimeException e)
D catch (Throwable | Error e)
Question page & discussion
Question 10 Medium

Which form is legal?

A try { } alone
B try { } finally { }
C catch { } alone
D finally { } alone
Question page & discussion

Ready to test your Programming?

Timed online tests with instant scores and explanations.

Search LearnFrenzy

Esc

Quick links