public class test1
{
static int cntr=0;
test1()
{ cntr++;
if(cntr>2)
throw new NullPointerException();//u can define a new exception // for this
}
public static void main(String args[])
{
test1 t1= new test1();
System.out.println("hello 1");
test1 t2= new test1();
System.out.println("hello 2");
test1 t3= new test1();
}
}
{
static int cntr=0;
test1()
{ cntr++;
if(cntr>2)
throw new NullPointerException();//u can define a new exception // for this
}
public static void main(String args[])
{
test1 t1= new test1();
System.out.println("hello 1");
test1 t2= new test1();
System.out.println("hello 2");
test1 t3= new test1();
}
}