Java Quizz Test your Java knowledge! 🚀 Take our tech quiz to sharpen your skills, challenge your understanding, and compete with others. Start quizzing today! 1 / 14 1. What is the default priority of a thread in Java? 5 0 1 10 2 / 14 2. Which of the following methods can be used to make a thread pause execution for a specific amount of time? pause() sleep() yield() wait() 3 / 14 3. What is the main purpose of the Stream.sorted method? To reverse the order of elements in the stream To sort the elements of the stream in their natural order or by a provided comparator To remove duplicate elements from the stream To randomly shuffle the elements of the stream 4 / 14 4. Which of the following is a valid lambda expression? (x, y) -> return x + y; All of the above (int x, int y) -> x + y x -> x*x 5 / 14 5. Which of the following is a checked exception? NullPointerException ArrayIndexOutOfBoundsException IOException ArithmeticException 6 / 14 6. In which of the following type of ResultSet, the cursor can only move forward in the result set? None of the above. ResultSet.TYPE_SCROLL_INSENSITIVE ResultSet.TYPE_SCROLL_SENSITIVE ResultSet.TYPE_FORWARD_ONLY 7 / 14 7. What is the output of the following code? try { int a = 10 / 0; } catch (ArithmeticException e) { System.out.println("Exception caught"); } finally { System.out.println("Finally block"); } Exception caught Finally block Finally block Exception caught 8 / 14 8. What will be the output of the below statements? public class Test { public static void main(String[] args) { String s1 = "abc"; StringBuffer s2 = new StringBuffer(s1); System.out.println(s1.equals(s2)); } } ClassCastException at runtime false true Compile-time error 9 / 14 9. Which method is used to transform each element of a Stream using a provided function? flatMap reduce map filter 10 / 14 10. Which of the following is correct about setFetchSize(int)? None of the above. setFetchSize(int) affects how the database returns the ResultSet data. setFetchSize(int) defines the number of rows that will be read from the database when the ResultSet needs more rows. Both of the above. 11 / 14 11. Select all the classes that extend the String class StringBuffer StringBuilder None StringWriter 12 / 14 12. What is the result of applying the Stream.reduce operation? A list of elements that were reduced An Optional describing the reduced value, if any A new stream with elements reduced according to a provided accumulator function A boolean indicating if any stream elements match a given predicate 13 / 14 13. Which method is used to start a thread in Java? run() init() execute() start() 14 / 14 14. Which of the following is correct about PreparedStatement? None of the above. PreparedStatement allows mapping different requests with same prepared statement but different arguments to execute the same execution plan. Both of the above. Prepared statements are more secure because they use bind variables, which can prevent SQL injection attack. Your score is 0%