Exception Handling

37. Program

//Find what it gives ?

Compiletion Error / Compiletion Successfully / Run Time Error / Output // throw Keyword Use class A { public static void main(String[] args) { System.out.println(1); if(true) { throw new ArithmeticException(); } // here we explicitly error raiseing System.out.println("done"); } }

38. Program

//Find what it gives ?

Compiletion Error / Compiletion Successfully / Run Time Error / Output // throw Keyword Use class B { public static void main(String[] args) { System.out.println(1); if(true) { throw new NumberFormatException("Some msg"); } // here we explicitly error raiseing System.out.println("done"); } }

39. Program

//Find what it gives ?

Compiletion Error / Compiletion Successfully / Run Time Error / Output // throw Keyword Use class C { public static void main(String[] args) { System.out.println(1); if(true) { throw new OutOfMemoryError("Out of memory"); } // here we explicitly error raiseing System.out.println("done"); } }

40. Program

//Find what it gives ?

Compiletion Error / Compiletion Successfully / Run Time Error / Output // throw Keyword Use class D { public static void main(String[] args) { if(true) System.out.println(1); { System.out.println(3); throw new ClassNotFoundException("........"); } // here we explicitly error raiseing System.out.println(2); } }

41. Program

//Find what it gives ?

Compiletion Error / Compiletion Successfully / Run Time Error / Output //throw Keyword Use import java.util.*; class E { public static void main(String[] args) { System.out.println("Enter your Age"); Scanner sc = new Scanner(System.in); int i = sc.nextInt(); if(i < 18) { throw new ArithmeticException("you are not eligible for vote"); } else { System.out.println("you can"); } } }

Page....