❮ Previous Next ❯

Types of Exception..

There are mainly two types of exceptions: checked and unchecked where error is considered as unchecked exception. The sun Microsystems says there are three types of exceptions:

Checked Exception

Let's see an example for better clarity.

Example

import java.io.*;
class CheckedDemo
{
public static void main(String args[])
{
PrintWriter pw=new PrintWriter("f.txt");
pw.println("Welcome");
System.out.println(25/0);
}
}

Output


unreported exception FileNotFoundException; must be caught or declared to be thrown

Here when we are compiling this program, the compiler generated a report which represents that there may be a chance FileNotFoundException arises at run time if the welcome.txt file is not found. So in this way the compiler gave this message to the programmer. This is known as checked exception.

Unchecked Exception


Next ❯ ❮ Previous


  Tutorials

Popular Links

Contact Us

address Plot No-741,2ND Floor
Opp. Bhagabati Temple,Jayadev Vihar
      Bhubaneswar-751013
      Email: info@silantechnology.com
      Phone: 0674-2361252
address
39877, sundale dr, apt#101, Fremont, California 94538, USA
       Phone: +1(262)388-7619

facebook twitter google linked in

© 2018 Silan Technology. All Rights Reserved