You are on page 1of 1

class cgf

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

String ptr = null;


try
{
if (ptr.equals("gfg"))
System.out.print("Same");
else
System.out.print("Not Same");
}
catch(NullPointerException e)
{
System.out.print("NullPointerException Caught");
}
}
}

public class eee {

public static void main (String[] args)


{
int b=0,a=5;

try
{
if (b==0)
System.out.print(a/b);
else
System.out.print("Not Same");
}
catch(ArithmeticException e)
{
System.out.print("divide by zero exception Caught");
}
}
}

You might also like