Java Exceptions MCQs with answers
79 questions tagged Java Exceptions, each with the correct answer and an explanation. Page 3 of 4.
- Which exception is thrown if a method receives an illegal argument?
- Which is the correct syntax to define a method that throws IOException?
- What will this code print? try { int x = 10 / 0; } catch (ArithmeticException e) { System.out.print("Catch"); } finally {
- Which class represents errors that are not meant to be caught by applications?
- What is the correct way to rethrow an exception?
- Can we catch multiple exceptions in a single catch block in Java 7+?
- Which exception must be caught or declared to be thrown?
- What does the following code do? try { // code } catch (Exception e) {} finally {}
- What happens if multiple catch blocks match the same exception?
- Which method is required when you override a method that throws a checked exception?
- Which of these is a runtime exception?
- Which method in Throwable class prints the stack trace?
- Which exception occurs if a null object is accessed?
- What will happen? try { return; } finally { System.out.println("Finally"); }
- Which exception is thrown when casting an object to an incompatible type?
- Which statement is correct regarding checked exceptions?
- What type of exception is thrown by the `sleep()` method?
- Which of the following is NOT a subclass of java.lang.Exception?
- Which of these keywords is used to manually create an exception object and throw it?
- What is the correct order of catch blocks?