Interview Questions on Exception Handling in Java

How have you handled exceptions in the projects that you have worked on?

You can check the below link to learn about the basic exception handling in Java.

Have you used custom exceptions?

Why do we need custom exceptions?

How many types of exceptions are there?

Could you provide examples of checked and unchecked exceptions?

IOException is a checked exception while ArithmeticException is an unchecked exception.

Tell the output of the following:


Exception in thread “main” CustomException: Inside Finally block
at TestMain.main( 

What we notice here, is that the CustomException which is thrown inside catch block disappears. So let’s note this point that, only the last exception that is thrown inside try-catch-finally blocks, propagates up the call stack.

Is NullPointerException a checked exception?

No. It is an unchecked exception.

Receive our updates to your inbox

Get more stuff like this
in your inbox

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.