Sample code for the try block.
File:tr.java
class tr
{
public static void main(String ar[])
{
try
{
int a=1,b=3,c;
c=a+b;
System.out.println(“The added value ” +c);
}
catch(Exception e)
{
System.out.println(“Genereated Exception ” +e);
}
}
}
{
public static void main(String ar[])
{
try
{
int a=1,b=3,c;
c=a+b;
System.out.println(“The added value ” +c);
}
catch(Exception e)
{
System.out.println(“Genereated Exception ” +e);
}
}
}
Output:
The added value 4