Java Exceptions MCQs with answers
79 questions tagged Java Exceptions, each with the correct answer and an explanation. Page 1 of 4.
- Which keyword is not part of Java exception handling mechanism?
- What will the code throw? String[] arr = new String[-5];
- Which keyword is used to define a custom exception constructor with a message?
- What is the return type of `getMessage()` method of Throwable class?
- Which method can you override in a custom exception to provide custom message formatting?
- Which of these is the most specific exception type?
- Which exception occurs when accessing a method on a null reference?
- What happens when an exception is thrown in the finally block?
- Which of the following exceptions is thrown when accessing a character beyond the length of a string?
- How do you define a custom exception in Java?
- Which exception is thrown when a negative size is used for an array?
- Which of the following can be caught using a catch block?
- Can we write try block without catch or finally?
- What is the base class for all errors in Java?
- What kind of exception is FileNotFoundException?
- Which block in Java ensures execution whether an exception occurs or not?
- Can a catch block catch multiple exceptions using multi-catch in Java 6?
- What does the `throws` keyword indicate in a method declaration?
- Which of the following exceptions is a subclass of RuntimeException?
- Can we have multiple finally blocks in Java?