Skip to content

Advanced Java · Final project

Test

Step 1 of 3

Java 2 Final Test - Multiple Choice Questions

Quick check

  1. 1. What is the correct way to declare a 2D array in Java?

  2. 2. Which of the following is true about classes in Java?

  3. 3. What is encapsulation in Java?

  4. 4. Which keyword is used to implement inheritance in Java?

  5. 5. What is polymorphism in Java?

  6. 6. Which of the following is true about ArrayList in Java?

  7. 7. What is recursion in Java?

  8. 8. Which of the following is a correct way to initialize a 2D array in Java?

  9. 9. What is the purpose of the 'private' access modifier in Java?

  10. 10. Which of the following is true about method overriding in Java?

  11. 11. What is the output of the following code? ArrayList<String> list = new ArrayList<>(); list.add("A"); list.add("B"); list.add("C"); list.add(1, "D"); System.out.println(list);

  12. 12. Which of the following is true about abstract classes in Java?

  13. 13. What is the purpose of the 'super' keyword in Java?

  14. 14. Which of the following is true about the 'final' keyword in Java?

  15. 15. What is the correct way to declare a method that throws an exception in Java?

  16. 16. Which of the following is NOT a valid way to iterate over an ArrayList in Java?

  17. 17. What is the output of the following recursive method call? public static int mystery(int n) { if (n == 0) return 0; return n + mystery(n - 1); } System.out.println(mystery(5));

  18. 18. Which of the following is true about interfaces in Java?

  19. 19. What is the purpose of the 'instanceof' operator in Java?

  20. 20. Which of the following is true about method overloading in Java?