Java MCQ Test: Java MCQs - Practice Questions
1. Which of these is not a valid keyword in Java?
2. What is the correct way to handle multiple exceptions in a single catch block?
3. Which of these is not a valid way to create an instance of a Thread in Java?
4. Which of the following is a valid declaration of a char array?
5. What does the operator '>>>' do in Java?
6. Which of these is a correct way to declare a multi-dimensional array in Java?
7. Which of these access modifiers makes a member visible to all classes everywhere?
8. Which method must be implemented by a class that implements the Runnable interface?
9. What does the 'public' keyword in a class definition specify?
10. What is the purpose of 'final' keyword in Java?
11. What is the default value of a boolean variable in Java?
12. What is the initial capacity of Java's Vector class?
13. What will this code return: boolean a = true; boolean b = !true && (a = false); System.out.println(a);
14. Which of these is an incorrect array declaration in Java?
15. What is the correct way to create an object in Java?
16. What is the use of the 'super' keyword in Java?
17. What does the 'static' keyword signify in Java?
18. What will be the output of the following Java code? class Test { public static void main(String args[]) { try { int a = 0; System.out.println("a = " + a); } finally { System.out.println("finally block is executed"); } } }
19. What will this code print? int arr[] = {1, 2, 3, 4, 5}; System.out.println(arr[2]);
20. What is the output of this Java code snippet? int arr[] = new int[5]; System.out.println(arr);
21. Which of these is a correct method to convert a string to an integer in Java?
22. In Java, what is the default size of the byte data type?
23. What is the default layout manager for a JPanel?
24. In Java, which of these methods is used to start a thread?
25. In Java, which of these can be used to achieve polymorphism?
26. What is the term for the process of converting objects into a byte stream in Java?
27. What is the starting index for arrays in Java?
28. What does 'this' keyword refer to in Java?
29. Which of these is not a valid lifecycle method in a Java Applet?
30. What is the default value of a local variable in Java?