
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Difference Between Checked and Unchecked Exception in Java
In this post, we will understand the difference between checked and unchecked exceptions in Java.
Checked Exceptions
They occur at compile time.
The compiler checks for a checked exception.
These exceptions can be handled at the compilation time.
It is a sub-class of the exception class.
The JVM requires that the exception be caught and handled.
Example of Checked exception- ‘File Not Found Exception’
Unchecked Exceptions
These exceptions occur at runtime.
The compiler doesn’t check for these kinds of exceptions.
These kinds of exceptions can’t be caught or handled during compilation time.
This is because the exceptions are generated due to the mistakes in the program.
These are not a part of the ‘Exception’ class since they are runtime exceptions.
The JVM doesn’t require the exception to be caught and handled.
Example of Unchecked Exceptions- ‘No Such Element Exception’
- Related Questions & Answers
- What is the difference between checked and unchecked exceptions in Java?
- While chaining, can we throw unchecked exception from a checked exception in java?
- Are the instances of Exception checked or unchecked exceptions in java?
- Checked vs Unchecked exceptions in Java
- Checked Vs unchecked exceptions in Java programming.
- How can we decide that custom exception should be checked or unchecked in java?
- Checked vs Unchecked Exceptions in C#
- Difference between Exception and Error in Java
- Difference Between Error and Exception in Java
- How to create a custom unchecked exception in Java?
- Difference between system level exception and Application level exception.
- Can we change an exception of a method with throws clause from unchecked to checked while overriding it in java?
- Can we throw an Unchecked Exception from a static block in java?
- Difference between Java and JavaScript.
- Difference between Go and Java.