Java Exceptions MCQs with answers Page - 4

You will find multiple-choice questions (MCQs) related to #Java Exceptions here. Go through these questions to prepare effectively for your upcoming exams and interviews.

To view the correct answer for any question, simply click the "Show Answer" button.

Have a question to share? Click on "Add Question" to contribute!

A

Admin • 831.35K Points
Coach

Q. What happens if multiple catch blocks match the same exception?

  • (A) First matching catch block executes
  • (B) Last matching catch block executes
  • (C) All matching blocks execute
  • (D) Runtime error occurs

A

Admin • 831.35K Points
Coach

Q. What does the following code do?
try {
// code
} catch (Exception e) {}
finally {}

  • (A) Only executes if exception occurs
  • (B) Executes regardless of exception
  • (C) Only runs finally block
  • (D) Throws compile error

A

Admin • 831.35K Points
Coach

Q. Which exception must be caught or declared to be thrown?

  • (A) ArithmeticException
  • (B) IOException
  • (C) NullPointerException
  • (D) ClassCastException

A

Admin • 831.35K Points
Coach

Q. Can we catch multiple exceptions in a single catch block in Java 7+?

  • (A) Yes, using pipe symbol (|)
  • (B) No, only one catch allowed
  • (C) Yes, using comma
  • (D) Only for runtime exceptions

A

Admin • 831.35K Points
Coach

Q. What is the correct way to rethrow an exception?

  • (A) throw e;
  • (B) throws e;
  • (C) rethrow(e);
  • (D) new throw e();

A

Admin • 831.35K Points
Coach

Q. Which class represents errors that are not meant to be caught by applications?

  • (A) Exception
  • (B) RuntimeException
  • (C) Error
  • (D) Throwable

A

Admin • 831.35K Points
Coach

Q. What will this code print?
try {
int x = 10 / 0;
} catch (ArithmeticException e) {
System.out.print("Catch");
} finally {
System.out.print("Finally");
}

  • (A) Catch
  • (B) Finally
  • (C) CatchFinally
  • (D) Exception

A

Admin • 831.35K Points
Coach

Q. Which is the correct syntax to define a method that throws IOException?

  • (A) void method() throw IOException {}
  • (B) void method() throws IOException {}
  • (C) throws IOException void method() {}
  • (D) throw IOException void method() {}

A

Admin • 831.35K Points
Coach

Q. Which exception is thrown if a method receives an illegal argument?

  • (A) IllegalStateException
  • (B) IllegalArgumentException
  • (C) RuntimeException
  • (D) InputMismatchException

A

Admin • 831.35K Points
Coach

Q. Which of these methods are present in the Throwable class?

  • (A) getMessage()
  • (B) getCause()
  • (C) printStackTrace()
  • (D) All of the above
What's Tag

As you may know, questions are organized under broad categories. Each category can include various types of questions. For example, the "History" category might contain questions about the Revolt of 1857, Shivaji Maharaj, Ancient History, Buddhism, and more.

To further refine this organization, we've introduced tags, which act as sub-categories to group questions more specifically.

Verified users can add tags to any question. If you have any suggestions regarding this system, we'd love to hear from you. Contact Us

Learn More