Download the BYJU'S Exam Prep App for free GATE/ESE preparation videos & tests - Download the BYJU'S Exam Prep App for free GATE/ESE preparation videos & tests -

Differences between Checked and Unchecked Exceptions in Java

An exception in Java is a spontaneous event that occurs during the runtime that can interrupt the regular flow of the program. There are two types of exceptions:

  1. Checked exceptions
  2. Unchecked exceptions

What is a Checked Exception?

A checked exception is an exception that should be reported in the method in which it is thrown.

What is an Unchecked Exception?

An exception that occurs at the runtime or at the time of execution is known as an unchecked exception.

Differences between Checked and Unchecked Exceptions in Java

S.No. Checked Exception Unchecked Exception
1. Checked exceptions happen at compile time when the source code is transformed into an executable code. Unchecked exceptions happen at runtime when the executable program starts running.
2. The checked exception is checked by the compiler.  These types of exceptions are not checked by the compiler.
3. Checked exceptions can be created manually. They can also be created manually.
4. This exception is counted as a sub-class of the class. This exception happens in runtime, and hence it is not included in the exception class.
5. Java Virtual Machine requires the exception to to be caught or handled. Java Virtual Machine does not need the exception to be caught or handled.

Keep learning and stay tuned to get the latest updates on GATE Exam along with GATE Eligibility Criteria, GATE 2023, GATE Admit CardGATE Application Form, GATE SyllabusGATE Cut off, GATE Previous Year Question Paper, and more.

Also Explore,

Comments

Leave a Comment

Your Mobile number and Email id will not be published.

*

*