Home [Development] Exception In Java
Post
Cancel

[Development] Exception In Java

Exception in Java

Screen Shot 2022-10-12 at 5 22 13 PM


Checked Exception vs Unchecked Exception

Β Checked ExceptionUnchecked Exception
When checkedchecked at compile time.not checked at compile time, it occurs at runtime.
Handling exceptionA checked must be handled either by re-throwing or with a try-catch blockwhereas an unchecked isn’t required to be handled.

Screen Shot 2022-10-12 at 5 39 11 PM


Checked Exception

  • These are the exceptions that are checked at compile time.
  • If some code within a method throws a checked exception, then the method must either handle the exception or it must specify the exception using the throws keyword.

A fully checked exception

  • A fully checked exception is a checked exception where all its child classes are also checked, like IOException, InterruptedException.

A partially checked exception

  • A partially checked exception is a checked exception where some of its child classes are unchecked, like Exception.

Unchecked Exception

  • These are the exceptions that are not checked at compile time.
  • It is not forced by the compiler to either handle or specify the exception. It is up to the programmers to be civilized, and specify or catch the exceptions.

[Reference]

This post is licensed under CC BY 4.0 by the author.

[Development] Elasticsearch

[Development] API vs Endpoint

Comments powered by Disqus.