Java Interview Questions
1. What are the main features of Java? Why is it platform-independent?
2. Explain the Java program compilation and execution process.
3. What is the role of the JVM, and how is it different from JRE and JDK?
4. Explain the JVM as an interpreter and emulator.
5. What is the difference between primitive data types and wrapper classes in Java?
6. Explain variables, literals, arrays, and operators in Java.
7. Differentiate between == and equals().
8. What are control flow statements in Java? Give examples.
9. What is the difference between class and object?
10. Explain inheritance in Java with an example.
11. What are interfaces and abstract classes? How do they differ?
12. Explain anonymous inner classes with an example.
13. What are access modifiers in Java?
14. How is exception handling done in Java? Explain throw vs throws.
15. How do you create user-defined exceptions in Java?
16. What is the class file format in Java?
17. What is the instruction set of the JVM?
18. Explain the role of Bytecode Verifier.
19. Differentiate between Class Area, Heap, and Java Stack.
20. How does Garbage Collection work in Java?
21. Explain the Security Architecture of JVM.
22. What is a Security Policy in Java?
23. How do Class Loaders affect Java security?
24. What is the sandbox model in Java?
25. How do you create a thread in Java?
26. What are the differences between extending Thread class and implementing Runnable?
27. What is the role of thread priority?
28. Explain different thread states.
29. What is thread synchronization?
30. How does a synchronized method differ from a synchronized block?
31. Explain wait(), notify(), notifyAll() with examples.
32. What is a deadlock in multithreading? How can it be prevented?
33. What is an applet in Java?
34. Explain the life cycle of an applet.
35. What are security concerns with applets?
36. What is the Component class in AWT?
37. Differentiate between Container and Component.
38. What is the role of Layout Managers in AWT?
39. Explain FlowLayout, BorderLayout, GridLayout, CardLayout, GridBagLayout.
40. What are AWT Events and Event Listeners?
41. Differentiate between Listener classes and Adapter classes.
42. Explain ActionEvent, KeyEvent, MouseEvent, WindowEvent with examples.
43. What are Input/Output streams in Java?
44. Difference between Byte streams and Character streams.
45. What are Buffered streams? Why are they used?
46. What is a RandomAccessFile?
47. Explain Object Serialization in Java.
48. What is a Socket in networking?
49. Explain client-server application development in Java.
50. How do you design a multithreaded server?
51. What is the difference between URL connection and socket programming?
52. What is RMI (Remote Method Invocation)?
53. How does parameter passing work in RMI?
54. Explain the steps to implement an RMI application.
55. What is JNI (Java Native Interface), and when is it used?
56. What is JDBC?
57. Explain the steps to connect Java with a database.
58. How do you connect Java with MS-Access / Oracle / MySQL?
59. Explain Statement vs PreparedStatement vs CallableStatement.
60. What are the advantages of connection pooling?
61. What is the Collections API in Java?
62. Difference between List, Set, and Map.
63. How are Vector, Stack, and Hashtable different?
64. What is an Iterator? How is it different from Enumeration?
65. Explain the difference between HashMap and Hashtable.
66. What is the difference between ArrayList and LinkedList?
67. What is a Servlet?
68. Explain the Servlet architecture.
69. What are the life cycle methods of a servlet?
70. Difference between doGet() and doPost().
71. How is session tracking done in Servlets?
72. What is the role of cookies in Servlets?
73. What is JSP, and how is it different from Servlets?
74. Explain the life cycle of JSP.
75. What are implicit objects in JSP?
76. Explain scripting elements: declaration, scriptlet, expression.
77. What are standard actions in JSP?
78. Explain the difference between JSP directives (page, include, taglib).
79. What is JSTL (JSP Standard Tag Library)?
80. What is a Java Bean?
81. What are the requirements for a class to be a Bean?
82. What are the different types of properties in Java Beans?
83. Differentiate between Stateless Session Bean and Stateful Session Bean.
84. What is an Entity Bean?
85. What is Hibernate? Why use it over JDBC?
86. Explain the architecture of Hibernate.
87. What is a SessionFactory and a Session in Hibernate?
88. What is the difference between HQL and SQL?
89. What are persistent, detached, and transient objects in Hibernate?
90. Explain caching in Hibernate.
91. How would you handle deadlock in Java threads?
92. If two servlets need to share data, how would you design it?
93. How do you secure a JSP/Servlet application?
94. What is the difference between JDBC and Hibernate?
95. How would you design a multithreaded RMI-based client-server application?