Java Common Checked Exceptions

There are some common checked exceptions occur in day to day java programming. Here we are going to see scenarios when those checked exceptions may occur.

1) FileNotFoundException

Thrown when pathname is wrong or not having access to the given pathname or pathname could be a folder … etc.

Output :

Exception in thread “main” C:\fileNotFound.txt (Access is denied)
java.lang.NullPointerException: Cannot invoke “” because “fw” is null
at com.vidvaan.corejava.exception17.common.checked.exceptions.FileNotFoundExceptionDemo.main(

2) ParseException

Thrown when something wrong either with the input String you are providing to the parse() method, or with the Format you are providing

Output :

java.text.ParseException: Unparseable date: “02 02 2020”
at java.base/java.text.DateFormat.parse(
at com.vidvaan.corejava.exception17.common.checked.exceptions.ParseExceptionDemo.main(

3) InterruptedException 

Thrown when a thread is waiting, sleeping, or otherwise paused for a long time and another thread interrupts it using the interrupt method of Thread class.

Output :

An InterruptedException was caught: sleep interrupted

4) ClassNotFoundException

Thrown when JVM fails to load the specified class.

The following example tries to load a class “com.mysql.jdbc.InvalidDriverClass” using the Class.forName() method. However the specified class name cannot be found and thus a ClassNotFoundException is thrown.

Output :

Trying to load class which doesn’t exist
Exception in thread “main” java.lang.ClassNotFoundException: com.mysql.jdbc.InvalidDriverClass
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(
at java.base/java.lang.ClassLoader.loadClass(
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(
at com.vidvaan.corejava.exception17.common.checked.exceptions.ClassNotFoundExceptionDemo.main(

5) MalformedURLException

Thrown when the built-in URL class encounters an invalid URL

Output : unknown protocol: htp
at java.base/
at java.base/
at java.base/
at com.vidvaan.corejava.exception17.common.checked.exceptions.MalformedURLExceptionDemo.main(

Scroll to Top