InstructionsTotal Questions: 18Total Minutes: 18This ExamTray Free Online Test or Quiz or Trivia tests your Programming Skills on the basics of Java Exception Handling. This practice test displays answers after finishing the exam for review. You can easily clear Competitive Exams and Job Interview Questions. Students can learn Java basics. Go through Java Theory Notes on Exception Handling and Java Theory Notes on Try-With-Resource before attempting this test. All the Best Challenge SCORE0 / 18Take This Exam 1*2*3*4*5*6*7*8*9*10*11*12*13*14*15*16*17*18*Q Buttons 1) What is the output of the below Java code with exceptions? public class ExceptionTest8 { public static void main(String[] args) throws ArithmeticException { System.out.println("I am happy."); throw new ArithmeticException(); } } A) I am happy. B) No output C) Compiler error D) None of the above 2) What is the output of the Java code with exceptions? public class ExceptionTest9 { public static void main(String[] args) { System.out.println("I am going to forest."); throw new ClassNotFoundException(); } } A) I am going to forest. B) No output C) Compiler error D) None of the above 3) What is the output of the below Java code with exception handling keywords? public class ExceptionTest10 { public static void main(String[] args) throws Exception { System.out.println("Good Morning Cortana."); throw new NoSuchMethodException(); } } A) Good Morning Cortana. B) Good Morning Cortana. Exception in thread "main" java.lang.NoSuchMethodException at Project1/package1.ExceptionTest10.main(ExceptionTest10.java:8) C) Compiler error D) None of the above 4) What are the difference between Checked and Unchecked exceptions in Java? A) Unchecked exceptions produce less number of compiler errors than the code with Checked exceptions. B) Most of the unchecked exceptions have RuntimeException as the superclass. Checked exceptions have different classes are superclasses. C) Unchecked exceptions cause more number of runtime exceptions at the time of execution. As the Checked exceptions are handled well with TRY CATCH blocks, you will get less number of exceptions or errors at the time of execution. D) All the above 5) Can you catch an object of type Error in Java using TRY-CATCH blocks? A) Yes B) No C) - D) - 6) Which is the superclass of Error class in Java? A) RuntimeException B) Exception C) Throwable D) None of the above 7) An Error is treated like a _____ type of exception by the compiler. A) Unchecked B) Checked C) - D) - Ad 8) Which is the exception handling block that closes the used resources inside of it automatically in Java? A) TRY B) CATCH C) FINALLY D) TRY with resource 9) Choose the correct syntax of a try-with-resource in Java. A) try(var1 initialized; var2 initialized;) { } B) try(var1; var2;) { } C) try(var1 initialized, var2 initialized;) { } D) try(var1 uninitialized, var2 uninitialized;) { } 10) Who closes the resources using code in a TRY-with-resources block in Java? A) Compiler B) Runtime C) Programmer D) None 11) What is the output of the below Java program with Try With Resource block? import java.io.*; public class ExceptionTest12 { public static void main(String[] args) { try(BufferedWriter bw = new BufferedWriter(new FileWriter("abc.txt"));) { System.out.println("Inside Try With Resource block."); } catch(Exception e) { } } } A) Inside Try With Resource block. B) No output C) Compiler error D) None of the above 12) Is it possible to write Java code efficiently without using TRY-WITH-RESOURCE blocks? A) Yes B) No C) - D) - 13) A try-with-resource supports only the objects of classes to close automatically that implement ___ Interface in Java. A) java.lang.Closeable B) java.lang.AutoCloseable C) Both A and B D) None 14) What is the output of the below Java program with nested exceptions? public class ExceptionTest14 { public static void main(String[] args) { try { int a=10/1; try {int b=20/1;} catch(Exception e1) { System.out.println("b=20"); } } catch(Exception e2) {System.out.println("a=10");} } } A) a=10 b=20 B) b=20 a=10 C) Compiler error D) No output Ad 15) Choose the right statement about nesting of try-catch-finally in Java? A) try { try{} catch(Exception e1){} finally{} } catch(Exception e2) {} B) try { try{} catch(Exception e1){} finally{} } catch(Exception e2) { try{} catch(Exception e3){} finally{} } C) try { } catch(Exception e2) { } finally { try{} catch(Exception e3){} finally{} } D) All the above 16) The variables initialized inside a TRY-with-resource are treated like ____ variables in Java. A) static B) instance C) final D) None of the above 17) An exception of user-generated-type is treated like a ___ exception. A) Checked B) Unchecked C) - D) - 18) What is the output of the Java code with custom exceptions? public class ExceptionTest15 { void show(int a) throws MyException { System.out.println("Hello Custom Exception"); int b = a/0; } public static void main(String[] args) { ExceptionTest15 obj = new ExceptionTest15(); obj.show(5); System.out.println("Bye Custom Exception"); } } class MyException extends Exception { MyException(){ super();} MyException(String name){ super(name); } } A) Hello Custom Exception Bye Custom Exception B) Hello Custom Exception C) Bye Custom Exception D) Compiler error FINISH EXAM 1*2*3*4*5*6*7*8*9*10*11*12*13*14*15*16*17*18*PREV Java Exception Handling Online Test 1 NEXT Java Online Test on Wrapper Classes Certification Group ID 0