Java Exceptions MCQs with answers Page - 5

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. Which block executes even when a return statement is encountered in the try block?

  • (A) catch
  • (B) finally
  • (C) throw
  • (D) none

A

Admin • 831.35K Points
Coach

Q. Which of these exceptions is thrown if an application tries to use `null` in a case where an object is required?

  • (A) IllegalArgumentException
  • (B) IOException
  • (C) NullPointerException
  • (D) IllegalStateException

A

Admin • 831.35K Points
Coach

Q. Which exception occurs when parsing an invalid number format?

  • (A) ParseException
  • (B) NumberFormatException
  • (C) IllegalArgumentException
  • (D) FormatMismatchException

A

Admin • 831.35K Points
Coach

Q. Can we use `try` without a `catch` block?

  • (A) Yes, if finally is used
  • (B) No, it's invalid
  • (C) Yes, always
  • (D) Only in Java 11+

A

Admin • 831.35K Points
Coach

Q. What is the correct order of blocks in Java exception handling?

  • (A) try-finally-catch
  • (B) catch-try-finally
  • (C) try-catch-finally
  • (D) finally-try-catch

A

Admin • 831.35K Points
Coach

Q. Which method can be used to get the detail message of an exception?

  • (A) printStackTrace()
  • (B) getMessage()
  • (C) toString()
  • (D) getCause()

A

Admin • 831.35K Points
Coach

Q. What happens if an exception is thrown inside a catch block?

  • (A) Ignored
  • (B) Handled silently
  • (C) Must be caught again
  • (D) It propagates up the call stack

A

Admin • 831.35K Points
Coach

Q. Which of these is the base class for all errors and exceptions?

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

A

Admin • 831.35K Points
Coach

Q. Which type of exception must be either caught or declared?

  • (A) Unchecked exceptions
  • (B) RuntimeException
  • (C) Checked exceptions
  • (D) Error

A

Admin • 831.35K Points
Coach

Q. What does `super(message)` do in a custom exception class?

  • (A) Prints message
  • (B) Saves message in JVM logs
  • (C) Passes message to Exception superclass
  • (D) Throws exception
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