Java Quiz 1 – Advanced Sharing is caring Welcome to your Java Quiz 1 - Advanced 1. When is the finalize() method called? Before garbage collection After catching exception in the catch block Before a variable goes out of scope Before an object goes out of scope None 2. What is the output of the following code? try{ int Integer = 50/0; } catch(Exception e){ System.out.println(“from exception”); } catch(ArithmeticException ae){ System.out.println(“from Arithmetic exception”); } Infinity compilation error from Arithmetic exception from exception None 3. What does the following code do to the String “camera”? “camera”.replace(‘a’,’I’) Replaces first occurrence of ‘a’ to ‘I’ Replaces all occurrences of ‘a’ to ‘I’ Replaces any occurrence of ‘I’ to ‘a’ Replaces last occurrence of ‘a’ to ‘I’ None 4. What is the implicit return type of a constructor? No return type None A class object in which it is defined void None 5. What is output of the following code? int Integer = 50; char String = ‘I’; System.out.print(Integer); System.out.print(String); 50+I Compilation error Runtime error 50I None 6. Which of the following keyword when used before a variable, makes it a class level variable and not an instance variable? final volatile abstract static None 7. Which of the following is a valid syntax for declaring an array? None 8. In which of the following is toString() method defined? java.lang.util java.util.Function java.lang.Object java.lang.String None 9. Identify the modifier which cannot be used for constructor protected static public private None Please fill in the comment box below. Name Email Time's up Sharing is caring