The exception refers to an exceptional event. Exception is an event that disrupts the normal flow of the program, during program execution.
When an error occurs within a method, the method creates an object and hands it to the runtime system. This object is known as an exception object. It contains the information of the error.
Throwing an exception:
It is a process of handing an exception object to the runtime system.
Catch the exception:
It is a process of finding something that can handle an exception object.
It is a block of code that can handle the exception and is known as an exception handler.
Java exception handling tutorial:
- Exception handling in java.
- try and catch blocks
- Multiple catch blocks
- Nested try block
- Exception propagation
- Exception handling with method overriding
- Custom exception
- Throwable class
Interview Questions on Exception Handling
- what is an exception?
- How the exceptions are handled in java?
- What is the difference between error and exception in java?
- Can we keep other statements in between try catch and finally blocks?
- Explain the exception hierarchy in java?
- What are runtime exceptions in java?
- What is outofmemoryerror in java?
- What are checked and unchecked exceptions in java?
- What is the difference between classnotfoundexception and noclassdeffounderror in java?
- Will finally block get executed if return?
- Can we throw an exception without throws?
- What is rethrowing an exception in java?
- What is the use of throws keyword in java?
- What is exception propagation in java?
- Difference between throw and throws in java?
- What is finally in java?
- What is the difference between final finally and finalize in java?
- How to create customized exceptions in java?
- What is classcastexception in java?
- What is stackoverflowerror in java?
- What is the superclass of all exception classes?
- What is the use of printstacktrace method in java?
- What is arraystoreexception in java?