Monday, 20 May 2013

An exception is a problem that arises during the execution of a program.
A exception is nothing but unhandle condition that result into termination of program.


There are two type of Exception
1)Cheked Exception 
2)Uncheked Exception


Throwable is a super class of all Exceptions.



Class Exe
{



int a=10;
int b=0;

public void showResult()
{

int c=a/b;
System.out.println("Result Is"+c);

}
public static void main(String args[])
{


Exc c1=new Exc();\

c1.showResult();
}
}



Error: Divided by zero error




Handling Exception


Class Exe
{



int a=10;
int b=0;

public void showResult()
{
try
{

int c=a/b;
System.out.println("Result Is"+c);

}
}
catch(Exception es)
{
System.out.println("Error is"+es.getMessage());
}
public static void main(String args[])
{


Exc c1=new Exc();\

c1.showResult();
}
}

Aryantech India pune


No comments:

Post a Comment