You are on page 1of 7

1.

public class A

{
public static void main(String[] args)
{
System.out.println("main1");
int i=10/0;
System.out.println("main2");
}
}
2.

public class A1

{
public static void main(String[] args)
{
System.out.println("main");
try
{
System.out.println("try");
int i=10/0;
}
catch(ArithmeticException ex)
{
System.out.println("catch");
System.out.println(ex.getMessage());
}
System.out.println("main2");
}
}
3.

public class A11


{
public static void main(String[] args)
{
System.out.println("main");
try
{
//int i=10/0;
System.out.println("try");

}
//int i=90;
catch(ArithmeticException ex)
{
System.out.println("catch");
//ex.printStackTrace();
}
System.out.println("main2");
}
}
4.

public class B
{
public static void main(String[] args)
{
//int j=10/0;
System.out.println("main1");
try
{
int i=10/0;
}
catch(ArithmeticException ex)
{
System.out.println(ex);
}
System.out.println("main2");
}
}
5.

public class B1
{
public static void main(String[] args)
{
System.out.println("main");
try
{
System.out.println("try");
int i=10/0;

}
catch(ArithmeticException ex)
{
System.out.println("catch");
}
catch(NullPointerException ex)
{
System.out.println("catch");
}
catch(Exception ex)
{
System.out.println("catch");
}
finally
{
System.out.println("finally");
}
System.out.println("main2");

//
//
//
//
//
//
//
//

}
}
6.

public class C

{
static void test() throws ArithmeticException
{
int i = 10 / 0;
}
public static void main(String[] args)
{
try
{
test();
}
catch(ArithmeticException ex)
{
System.out.println(ex);
}
System.out.println("main");

}
}
7.

public class D
{
public static void main(String[] args)
{
//int j=10/0;
try
{
System.out.println("try");
//int i=10/0;
System.exit(0);
}
catch(ArithmeticException ex)
{
System.out.println(ex);
}
finally
{
System.out.println("finally");
}
}
}
8. public class E implements Cloneable
{
public static void main(String[] args) throws Exception
{
E e1=new E();
e1.clone();
//
try
//
{
//
e1.clone();
//
}
//
catch(CloneNotSupportedException ex)
//
{
//
System.out.println(ex);
//
}
}

}
9.

public class F
{
static void test() throws ArithmeticException
{
int i = 10 / 0;
}
public static void main(String[] args)
{
System.out.println("main");
try
{
test();
} catch (ArithmeticException ex)
{
System.out.println(ex);
}
System.out.println("main2");
}
}
10.

public class G

{
static void test() throws ArithmeticException
{
System.out.println("test");
int i = 10 / 0;
}
void test1() throws ArithmeticException
{
System.out.println("test1");
test();
}
public static void main(String[] args)
{

G g1 = new G();
System.out.println("main");
try
{
g1.test1();
} catch (ArithmeticException ex)
{
System.out.println(ex);
}
System.out.println("main2");
}
}
11.

public class H

{
void test()
{
System.out.println("test");
}
public static void main(String[] args)
{
H h1 = new H();
h1 = null;
// h1.test();
Object obj = new Object();
h1 = (H) obj;
}
}
12.

public class I

{
public static void main(String[] args)
{
try
{
Thread.sleep(890);
}
catch(Exception ex)
{
System.out.println(ex);

}
catch(Throwable ex)
{
System.out.println(ex);
}
}
}
13.

public class J

{
public static void main(String[] args) throws Exception
{
Thread t1=new Thread();
t1.join();
}
}
14.

package thro;

import java.util.Scanner;
public class A
{
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
System.out.println("enter the age");
int age=sc.nextInt();
if(age<=0)
{
throw new ArithmeticException("age shoul be +ve");
}
System.out.println("your age is:"+age);
}
}
15.

You might also like