Top 100 Java Interview Questions
1. What is Java?
2. What are the features of Java?
3. Explain JVM, JRE, and JDK.
4. What are the different data types in Java?
5. What is the default value of a boolean variable in Java?
6. What is type casting in Java?
7. What is the difference between implicit and explicit casting?
8. Explain static keyword in Java.
9. What is the main method signature in Java?
10. What are command-line arguments in Java?
11. What are the control statements in Java?
12. What is the difference between break and continue?
13. Explain the switch statement in Java.
14. Difference between while and do-while loops.
15. Write a Java program to print Fibonacci series.
16. Write a Java program to check if a number is prime.
17. Write a Java program to reverse a number.
18. Write a Java program to find factorial using recursion.
19. Write a Java program to find the largest of three numbers.
20. Write a Java program to check if a string is palindrome.
21. What is object-oriented programming?
22. What are the main principles of OOP?
23. What is the difference between class and object?
24. What is constructor in Java?
25. Types of constructors in Java.
26. What is constructor overloading?
27. What is method overloading and overriding?
28. What is inheritance in Java?
29. What is the use of super keyword?
30. What is encapsulation?
31. What is abstraction?
32. How is abstraction achieved in Java?
33. What is an interface in Java?
34. Difference between abstract class and interface.
35. What is polymorphism?
36. Difference between compile-time and runtime polymorphism.
37. What is the use of the final keyword?
38. What is a static method?
39. What is the 'this' keyword in Java?
40. What is a nested class?
41. How to declare and initialize an array in Java?
42. Difference between array and ArrayList.
43. Write a Java program to reverse an array.
44. Write a Java program to find duplicate elements in an array.
45. What is a String in Java?
46. Difference between String, StringBuffer, and StringBuilder.
47. How to reverse a string in Java?
48. What are string methods used in Java?
49. What is String immutability?
50. How to convert a string to a character array?
51. What is exception handling?
52. Difference between checked and unchecked exceptions.
53. What is try-catch block?
54. What is finally block?
55. What is throw and throws in Java?
56. How to create custom exceptions?
57. What is NullPointerException?
58. What are common runtime exceptions?
59. What is the use of try-with-resources?
60. How to handle multiple exceptions in a single catch?
61. What is the Collection framework in Java?
62. Difference between List, Set, and Map.
63. What is the difference between ArrayList and LinkedList?
64. What is HashSet in Java?
65. What is HashMap?
66. What is TreeSet and TreeMap?
67. What is Iterator in Java?
68. Difference between Iterator and ListIterator.
69. What are generics in Java?
70. What is the use of wildcard (?) in generics?
71. What is multithreading?
72. How to create a thread in Java?
73. Difference between Thread and Runnable.
74. What is synchronization in Java?
75. What is the use of volatile keyword?
76. What are daemon threads?
77. What is thread lifecycle?
78. What is deadlock? How to prevent it?
79. What is the difference between wait() and sleep()?
80. What is the use of join() in threads?
81. How to read and write files in Java?
82. What is serialization?
83. How to serialize and deserialize an object?
84. What is the transient keyword?
85. Difference between FileReader and BufferedReader.
86. How to create a file in Java?
87. How to list files in a directory?
88. What is ObjectOutputStream and ObjectInputStream?
89. What is PrintWriter in Java?
90. How to delete a file in Java?
91. What is JDBC?
92. What are JDBC drivers?
93. Steps to connect to a database using JDBC.
94. What is the difference between Statement and PreparedStatement?
95. What is connection pooling?
96. What is servlet in Java?
97. Difference between GET and POST in servlets.
98. What is the lifecycle of a servlet?
99. What is JSP?
100. Difference between JSP and Servlet?