Java Exceptions MCQs with answers Page - 3

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 these keywords is used to manually create an exception object and throw it?

  • (A) create
  • (B) throw
  • (C) throws
  • (D) raise

A

Admin • 831.35K Points
Coach

Q. Which of the following is NOT a subclass of java.lang.Exception?

  • (A) IOException
  • (B) SQLException
  • (C) Error
  • (D) ClassNotFoundException

A

Admin • 831.35K Points
Coach

Q. What type of exception is thrown by the `sleep()` method?

  • (A) IOException
  • (B) InterruptedException
  • (C) ArithmeticException
  • (D) IllegalArgumentException

A

Admin • 831.35K Points
Coach

Q. Which statement is correct regarding checked exceptions?

  • (A) They can be ignored by the programmer
  • (B) They must be handled or declared
  • (C) They are subclasses of RuntimeException
  • (D) They only occur at runtime

A

Admin • 831.35K Points
Coach

Q. Which exception is thrown when casting an object to an incompatible type?

  • (A) IllegalArgumentException
  • (B) ClassCastException
  • (C) IllegalCastException
  • (D) TypeMismatchException

A

Admin • 831.35K Points
Coach

Q. What will happen?
try {
return;
} finally {
System.out.println("Finally");
}

  • (A) Nothing is printed
  • (B) Finally
  • (C) Return
  • (D) Compile error

A

Admin • 831.35K Points
Coach

Q. Which exception occurs if a null object is accessed?

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

A

Admin • 831.35K Points
Coach

Q. Which method in Throwable class prints the stack trace?

  • (A) trace()
  • (B) print()
  • (C) printStackTrace()
  • (D) show()

A

Admin • 831.35K Points
Coach

Q. Which of these is a runtime exception?

  • (A) NumberFormatException
  • (B) IOException
  • (C) ParseException
  • (D) SQLException

A

Admin • 831.35K Points
Coach

Q. Which method is required when you override a method that throws a checked exception?

  • (A) Must declare the same exception or subclass
  • (B) Must declare any exception
  • (C) Can declare nothing
  • (D) Can throw Error only
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