Java Exceptions MCQs with answers Page - 8

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 of the following exceptions is thrown when accessing a character beyond the length of a string?

  • (A) IndexOutOfBoundsException
  • (B) NullPointerException
  • (C) StringIndexOutOfBoundsException
  • (D) CharSequenceException

A

Admin • 831.35K Points
Coach

Q. What happens when an exception is thrown in the finally block?

  • (A) It is ignored
  • (B) It overrides previous exception
  • (C) It crashes the program
  • (D) It cancels finally

A

Admin • 831.35K Points
Coach

Q. Which exception occurs when accessing a method on a null reference?

  • (A) NullMethodException
  • (B) NullAccessException
  • (C) NullPointerException
  • (D) IllegalStateException

A

Admin • 831.35K Points
Coach

Q. Which of these is the most specific exception type?

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

A

Admin • 831.35K Points
Coach

Q. Which method can you override in a custom exception to provide custom message formatting?

  • (A) printStackTrace()
  • (B) toString()
  • (C) message()
  • (D) print()

A

Admin • 831.35K Points
Coach

Q. What is the return type of `getMessage()` method of Throwable class?

  • (A) String
  • (B) Object
  • (C) Throwable
  • (D) void

A

Admin • 831.35K Points
Coach

Q. Which keyword is used to define a custom exception constructor with a message?

  • (A) message
  • (B) super
  • (C) this
  • (D) throws

A

Admin • 831.35K Points
Coach

Q. What will the code throw?
String[] arr = new String[-5];

  • (A) IndexOutOfBoundsException
  • (B) IllegalArgumentException
  • (C) NegativeArraySizeException
  • (D) ArrayIndexOutOfBoundsException

A

Admin • 831.35K Points
Coach

Q. Which keyword is not part of Java exception handling mechanism?

  • (A) throw
  • (B) throws
  • (C) finalize
  • (D) catch
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