Java exception handling is a powerful mechanism designed to manage runtime errors and maintain normal application flow. It relies on five core keywords try, catch, finally, throw, and throws to isolate risky code, catch specific error types, and guarantee resource cleanup. Exceptions are divided into checked exceptions (verified at compile-time) and unchecked exceptions (inheriting from RuntimeException), sitting beneath the universal Throwable superclass. Mastering exception hierarchy and proper propagation is essential for writing robust code and clearing technical certification exams.
Java Exception Handling MCQs
1 min read
Correct Answer: b) Throwable
Explanation:
The java.lang.Throwable class is the root class of the Java Exception hierarchy. Both Exception and Error classes inherit from it.
Correct Answer: b) throw
Explanation:
The 'throw' keyword is used to explicitly throw a single exception from within a method or block of code.
Correct Answer: a) throws
Explanation:
The 'throws' keyword is used in a method signature to declare the exceptions that can occur during the execution of the program.
Correct Answer: b) Checked exceptions are checked at compile time, unchecked at runtime.
Explanation:
Checked exceptions must be handled or declared at compile time, whereas unchecked exceptions occur at runtime and do not require explicit handling.
Correct Answer: c) NullPointerException
Explanation:
NullPointerException inherits from RuntimeException, making it an unchecked exception.
Correct Answer: b) It will cause a compile-time error.
Explanation:
A try block must be followed by at least one catch block or a finally block; otherwise, a compile-time error occurs.
Correct Answer: c) finally
Explanation:
The finally block is used to execute crucial code such as closing resources. It executes regardless of whether an exception is thrown or caught.
Correct Answer: b) When System.exit() is called in the try or catch block.
Explanation:
Calling System.exit() terminates the JVM completely, preventing the finally block from executing.
Correct Answer: b) Most specific to most general.
Explanation:
Multiple catch blocks must be ordered from the most specific subclass exception to the most general superclass exception; otherwise, it causes a compile-time error.
Correct Answer: a) ArrayIndexOutOfBoundsException
Explanation:
ArrayIndexOutOfBoundsException is thrown to indicate that an array has been accessed with an illegal index.
Correct Answer: c) To ensure that each resource is closed at the end of the statement.
Explanation:
Try-with-resources ensures that any resource that implements java.lang.AutoCloseable is closed automatically when the try block finishes.
Correct Answer: b) ArithmeticException
Explanation:
ArithmeticException is thrown when an exceptional arithmetic condition has occurred, such as integer division by zero.
Correct Answer: b) By extending the Exception or RuntimeException class.
Explanation:
Custom exceptions are created by extending the existing java.lang.Exception class or java.lang.RuntimeException class.
Correct Answer: c) printStackTrace()
Explanation:
printStackTrace() prints the throwable and its backtrace to the standard error stream, showing exactly where the exception occurred.
Correct Answer: a) Yes, but it is considered bad practice.
Explanation:
Java allows empty catch blocks. However, swallowing exceptions without logging or handling them is a bad practice.
Correct Answer: c) MemoryOutOfBoundsException
Explanation:
MemoryOutOfBoundsException does not exist in standard Java. The closest standard error is OutOfMemoryError.
Correct Answer: b) Handle it using try-catch or declare it using throws.
Explanation:
Checked exceptions enforce the handle-or-declare rule. The caller must either surround the call in a try-catch block or add a throws declaration.
Correct Answer: b) No
Explanation:
A try block can be followed by just a finally block. A catch block is not mandatory if finally is present.
Correct Answer: c) A severe problem that a reasonable application should not try to catch.
Explanation:
Errors represent severe, generally unrecoverable conditions in the JVM environment.
Correct Answer: b) Multi-catch using the pipe (|) operator.
Explanation:
Java 7 introduced the multi-catch block feature where multiple exceptions can be caught using the pipe (|) operator.
Correct Answer: b) Forwarding an exception to the calling method if not handled locally.
Explanation:
Exception propagation is the process where an unhandled exception drops down the call stack until it finds an appropriate catch block.
Correct Answer: b) Unchecked exceptions only.
Explanation:
By default, unchecked exceptions are automatically propagated up the call stack. Checked exceptions must be explicitly propagated.
Correct Answer: b) It overrides any exception thrown in the try or catch block.
Explanation:
If a finally block throws an exception, it masks any exception that was previously thrown in the try or catch block.
Correct Answer: a) Yes, and it overrides any return statement in the try or catch block.
Explanation:
Placing a return in a finally block will suppress any unhandled exceptions and override any previous return values.
Correct Answer: b) StackOverflowError
Explanation:
StackOverflowError extends VirtualMachineError, which extends Error. The others extend Exception.
Correct Answer: c) The detailed string message of the throwable.
Explanation:
getMessage() returns the detail message string that was provided when the exception object was created.
Correct Answer: c) It cannot throw any new or broader checked exceptions.
Explanation:
An overriding method can only throw the same checked exceptions, narrower checked exceptions, or unchecked exceptions.
Correct Answer: a) Yes, it is called exception rethrowing.
Explanation:
You can use the 'throw' keyword inside a catch block to rethrow the caught exception or throw a completely new one.
Correct Answer: b) NumberFormatException
Explanation:
NumberFormatException is thrown by methods like Integer.parseInt() when the string does not have the appropriate format.
Correct Answer: b) public static void main(String[] args) throws Exception
Explanation:
The 'throws' keyword must be used in the method signature to declare that the main method propagates exceptions.
Correct Answer: b) It causes a compile-time error.
Explanation:
In a multi-catch block, the exception alternatives cannot have a subclass-superclass relationship. Doing so results in a compilation error.
Correct Answer: b) When the JVM tries to load a class and cannot find its definition.
Explanation:
ClassNotFoundException is thrown when an application tries to load in a class through its string name but no definition could be found.
Correct Answer: b) ClassCastException
Explanation:
ClassCastException is a runtime exception thrown to indicate that the code has attempted to cast an object to a subclass of which it is not an instance.
Correct Answer: b) No
Explanation:
A single try block can have at most one finally block associated with it.
Correct Answer: c) It is accessible only within the try block.
Explanation:
Variables declared inside a try block have local scope strictly limited to that try block.
Correct Answer: b) Closeable or AutoCloseable
Explanation:
Resources used in try-with-resources must implement java.lang.AutoCloseable (or java.io.Closeable).
Correct Answer: c) Associating one exception with another by passing it to the constructor.
Explanation:
Exception chaining relates one exception to another (the 'cause'). It is done by passing the original exception to the constructor of the new exception.
Correct Answer: b) getCause()
Explanation:
The getCause() method of Throwable returns the cause of this throwable or null if the cause is nonexistent or unknown.
Correct Answer: a) NullPointerException
Explanation:
NullPointerException is a runtime exception thrown when attempting to invoke a method or access a field on a null reference.
Correct Answer: c) InterruptedException
Explanation:
InterruptedException is a checked exception thrown when a thread is waiting, sleeping, or otherwise occupied, and the thread is interrupted.
Correct Answer: c) Error (which acts like unchecked)
Explanation:
OutOfMemoryError extends Error. Errors are unchecked, meaning the compiler does not force you to handle or declare them.
Correct Answer: a) Yes, but it is highly discouraged.
Explanation:
Technically, because Error extends Throwable, you can catch it. However, it is bad practice because Errors represent unrecoverable states.
Correct Answer: b) throws
Explanation:
If a checked exception isn't handled within the method using try-catch, the method signature must include the 'throws' keyword.
Correct Answer: c) It is used to throw an exception instance explicitly.
Explanation:
The 'throw' keyword is followed by an instance of Throwable. It cannot throw multiple exceptions at once.
Correct Answer: b) It separates error handling code from regular business logic.
Explanation:
Exception handling provides a clean separation between normal execution code and error-handling code.
Correct Answer: a) IllegalArgumentException
Explanation:
IllegalArgumentException is thrown to indicate that a method has been passed an illegal or inappropriate argument.
Correct Answer: c) StringIndexOutOfBoundsException
Explanation:
StringIndexOutOfBoundsException is specifically thrown by String methods to indicate an index is out of bounds.
Correct Answer: a) Yes
Explanation:
Java fully supports nesting try-catch blocks. A try block can be placed inside another try block, catch block, or finally block.
Correct Answer: b) No
Explanation:
If the superclass method does not declare any checked exceptions, the overriding method in the subclass cannot declare any new checked exceptions.
Correct Answer: b) The value from the finally block is returned.
Explanation:
The finally block executes last before control is transferred. Its return statement will override any return statement executed in the try block.
Correct Answer: a) FileNotFoundException
Explanation:
FileNotFoundException is thrown when an attempt to open the file denoted by a specified pathname has failed.
Correct Answer: b) When an exception in the try block suppresses an exception thrown by the close() method.
Explanation:
In try-with-resources, if the try block throws an exception and the close() method also throws an exception, the latter is 'suppressed'.
Correct Answer: c) Using getSuppressed()
Explanation:
The getSuppressed() method of Throwable returns an array containing all exceptions that were suppressed by the try-with-resources statement.
Correct Answer: a) SocketTimeoutException
Explanation:
SocketTimeoutException is a subclass of InterruptedIOException that signals a timeout occurred on a socket read or accept.
Correct Answer: c) Unchecked Exception
Explanation:
IllegalThreadStateException extends IllegalArgumentException, which extends RuntimeException, making it an unchecked exception.
Correct Answer: b) Yes, separated by commas.
Explanation:
A method signature can declare multiple exceptions using the 'throws' keyword by separating them with commas.
Correct Answer: b) Exception
Explanation:
Extending 'Exception' (and not RuntimeException) creates a checked exception, which the compiler forces the programmer to handle or declare.
Correct Answer: c) Both catch and finally
Explanation:
Both catch and finally blocks are explicitly tied to a try block and cannot stand alone in Java code.
Correct Answer: b) The thread executing the initialization terminates.
Explanation:
If an unhandled RuntimeException is thrown during execution, it propagates up the stack and terminates the executing thread.
Correct Answer: b) It prevents the object from being fully initialized.
Explanation:
If a constructor throws an exception, the object creation fails, and the reference to the partially constructed object is not returned.
Correct Answer: b) OutOfMemoryError
Explanation:
OutOfMemoryError is thrown when the JVM cannot allocate an object because it is out of memory.
Correct Answer: c) No, IllegalArgumentException is typically used instead.
Explanation:
Java does not have an EmptyStringException. Developers typically throw IllegalArgumentException if a string is unexpectedly empty.
Correct Answer: b) try (Resource r = new Resource()) { }
Explanation:
The syntax for try-with-resources uses parentheses directly after the 'try' keyword to declare the resources.
Correct Answer: c) It causes a compile-time error.
Explanation:
The catch parameter in a multi-catch block is implicitly final. Assigning a new value to it results in a compile-time error.
Correct Answer: a) It throws an AssertionError if a boolean condition evaluates to false.
Explanation:
The assert statement tests a condition; if the condition is false, it throws an AssertionError.
Correct Answer: a) IOException
Explanation:
IOException is the base class for exceptions produced by failed or interrupted I/O operations.
Correct Answer: b) IllegalStateException
Explanation:
IllegalStateException signals that a method has been invoked at an illegal or inappropriate time.
Correct Answer: b) No, they are unchecked exceptions.
Explanation:
RuntimeExceptions and their subclasses are unchecked exceptions. The compiler does not require them to be caught or declared.
Correct Answer: a) Yes
Explanation:
Abstract methods can declare a 'throws' clause to enforce that implementations handle or declare specific exceptions.
Correct Answer: c) StackOverflowError
Explanation:
Deep or infinite recursion causes the application to exhaust the call stack, leading the JVM to throw a StackOverflowError.
Correct Answer: a) fillInStackTrace()
Explanation:
fillInStackTrace() is a method in Throwable that records the current state of the stack frames within the Throwable object.
Correct Answer: c) catch (NullPointerException | ArithmeticException e)
Explanation:
Using multi-catch (pipe operator |) is the best and most precise way to handle distinct exceptions in a single block.
Correct Answer: b) Adding an element to an unmodifiable collection.
Explanation:
UnsupportedOperationException is often thrown by collections created via Collections.unmodifiableList() when mutative operations are attempted.
Correct Answer: b) In reverse order of their creation.
Explanation:
Resources declared in a try-with-resources block are closed in the reverse order in which they were initialized.
Correct Answer: c) 'throw' explicitly throws an exception instance, 'throws' declares that a method may throw exceptions.
Explanation:
'throw' is used to throw a specific exception object. 'throws' is used in the method signature to indicate propagated exceptions.
Correct Answer: a) SQLException
Explanation:
SQLException is a checked exception that provides information on a database access error or other errors relating to JDBC.
Correct Answer: b) Yes, by extending the RuntimeException class.
Explanation:
Custom unchecked exceptions are created by subclassing RuntimeException.
Correct Answer: b) At runtime when an application tries to call a method that no longer exists in the class definition.
Explanation:
NoSuchMethodError is thrown if an application tries to call a specified method, but that method no longer exists in the linked class.
Correct Answer: d) None of them declare checked exceptions.
Explanation:
Standard functional interfaces in Java do not throw checked exceptions, requiring you to handle them internally.
Correct Answer: b) A collection was modified while iterating over it using a fail-fast iterator.
Explanation:
This exception is thrown when an object is modified concurrently while iterating over it, without using the iterator's own modification methods.
Correct Answer: c) StackTraceElement[]
Explanation:
getStackTrace() returns an array of StackTraceElement objects, each representing one stack frame.
Correct Answer: a) Yes
Explanation:
Nesting try-catch blocks is valid in Java. You can place a try-catch block inside another try, catch, or finally block.
Correct Answer: b) Checked exceptions must be either caught in a catch block or declared in the throws clause.
Explanation:
The Java compiler forces programmers to deal with checked exceptions by either handling them using try-catch or declaring them.
Correct Answer: c) It executes regardless of whether an exception is thrown or caught.
Explanation:
The primary design of the finally block is to ensure that cleanup code runs unconditionally.
Correct Answer: a) NegativeArraySizeException
Explanation:
NegativeArraySizeException is thrown when an application attempts to instantiate an array with a negative size.
Correct Answer: a) Yes
Explanation:
A subclass method is not required to throw the exceptions declared by the superclass method. It can handle them internally and drop the clause.
Correct Answer: b) NullPointerException
Explanation:
Invoking an instance method on a null reference throws a NullPointerException at runtime.
Correct Answer: c) Infinity
Explanation:
In Java, floating-point arithmetic handles division by zero by returning Infinity (or -Infinity, or NaN). ArithmeticException is only for integers.
Correct Answer: b) Exception
Explanation:
IOException extends Exception, making it a checked exception.
Correct Answer: c) thrown
Explanation:
'thrown' is not a keyword in Java. The valid keywords are try, catch, finally, throw, and throws.
Correct Answer: b) NoClassDefFoundError
Explanation:
NoClassDefFoundError is an Error thrown if the JVM or ClassLoader tries to load in the definition of a class and no definition can be found.
Correct Answer: c) Using a logging framework like Log4j or SLF4J.
Explanation:
Enterprise applications use logging frameworks to properly record, format, and route exception traces.
Correct Answer: a) Yes, using the multi-catch feature.
Explanation:
The multi-catch feature was designed specifically to catch distinct exception types that do not have a subclass-superclass relationship.
Correct Answer: a) throw new RuntimeException(e);
Explanation:
To wrap a checked exception, you pass the caught checked exception as the 'cause' to the constructor of an unchecked exception.
Correct Answer: c) InterruptedException
Explanation:
Thread.sleep() declares that it throws InterruptedException, which is thrown if the sleeping thread's interrupt flag is set by another thread.
Correct Answer: b) IOException
Explanation:
FileNotFoundException is a specific type of IOException, hence it inherits from it and is a checked exception.
Correct Answer: b) The first one that matches the exception type.
Explanation:
Java checks catch blocks in the order they appear. The first catch block that matches the exception is executed, and the rest are ignored.
Correct Answer: b) An object that must be closed after the program is finished with it.
Explanation:
A resource is an object (like a file stream or database connection) that needs explicit closing. It must implement AutoCloseable.
Correct Answer: a) Yes, if they are related in the inheritance hierarchy.
Explanation:
Like any Java objects, exceptions can be cast to other types within their class hierarchy.
Correct Answer: c) Rethrow the exception or wrap it in a custom runtime exception.
Explanation:
If a method cannot meaningfully resolve an error, the best practice is to propagate it upwards by rethrowing or wrapping it.
Related Posts

Python Multithreading & Concurrency MCQs
Python multithreading is a core concurrency feature that enables execution of multiple threads within a single process to handle concurrent…
October 19, 2026By MCQs Generator

Java Inheritance and Polymorphism MCQs
Java inheritance and polymorphism form the bedrock of Object-Oriented Programming (OOP), enabling code reuse and flexible runtime behavior. Inheritance allows…
October 19, 2026By MCQs Generator

JavaScript Closures MCQs for Senior Developer Interviews
A closure in JavaScript is formed when an inner function retains access to the variables of its outer enclosing lexical…
August 29, 2026By MCQs Generator
Related Categories

AI & Data Science MCQ
5 topics
By MCQs Generator

Arts & Humanities MCQ
4 topics
By MCQs Generator

Civil Engineering MCQ
4 topics
By MCQs Generator

Commerce & Business MCQ
4 topics
By MCQs Generator

Competitive Exams MCQ
5 topics
By MCQs Generator

Electrical & Electronics Engineering MCQ
3 topics
By MCQs Generator

General Knowledge MCQ
2 topics
By MCQs Generator

General Science MCQ
4 topics
By MCQs Generator

Law & Judiciary MCQ
3 topics
By MCQs Generator

Mechanical Engineering MCQ
4 topics
By MCQs Generator

Medical & Health Sciences MCQ
4 topics
By MCQs Generator

Modern Tech Fields MCQ
3 topics
By MCQs Generator