AJP Question Bank
1. What is network programming, and why is it important? (3)
2. What are the key differences between TCP and UDP? (3)
3. What are the differences between IPv4 and IPv6? (2)
4. What is the significance of port numbers in networking? (2)
5. What is a socket in Java, and how does it work? (5)
6. Explain the role of the ServerSocket class in Java. (3)
7. How do you handle exceptions when working with sockets in Java?
8. What is the purpose of socket.close()?
9. What is the client-server model in networking?
10. Explain the steps for creating a simple TCP client-server application in Java. (5)
11. What is the role of accept() in server-side programming? (2)
12. How can you implement a simple chat application using Java sockets? (5)
13. What is an IP address, and how is it assigned?
14. How does DNS translate domain names into IP addresses?
15. What is the role of the InetAddress class in Java?
16. How do you get the IP address of a machine from its hostname? (2)
17. Compare Socket with ServerSocket
18. Difference between AWT and Swings?
19. Write about Layout Manager and different types of Layouts Manager.
What is event-driven programming in Java Swing?
20. How does the ActionListener interface work in Java Swing?
21. What is the purpose of the KeyListener interface?
22. What is the difference between event source, event object, and event listener?
23. How do you create a JTextField in Swing?
24. Explain the use of setText() and getText() methods in JTextField.
25. What is the purpose of a JButton? How do you add an action listener to it?
26. Differentiate between JButton and JToggleButton.
27. How do you programmatically select or deselect a JToggleButton?
28. What is the difference between a JCheckBox and a JRadioButton?
29. How do you group multiple radio buttons so that only one can be selected at a time?
30. What method is used to check if a JCheckBox is selected?
31. How do you handle events for a JRadioButton in Java Swing?
32. What is the purpose of JViewport in Swing?
33. How do you add scrolling functionality to a component in Swing?
34. Explain the use of JScrollPane and its constructors.
35. How do you create a JSlider in Swing?
36. Explain the purpose of setMinimum(), setMaximum(), and setValue() in JSlider.
37. How do you add a ChangeListener to a JSlider?
38. What is the difference between a JList and a JComboBox?
39. How do you add multiple items to a JList dynamically?
40. What is a ListSelectionListener and how is it used in JList?
41. What is JTable in Swing?
42. How do you define the number of rows and columns in a JTable?
43. Explain the DefaultTableModel in Swing.
44. What is a JTree and how is it structured?
45. How do you create a simple hierarchical structure in JTree?
46. How do you create a JComboBox in Swing?
47. How do you add items to a JComboBox dynamically?
48. What is the difference between setSelectedItem() and getSelectedItem() in
JComboBox?
49. What is the purpose of JTabbedPane in Swing?
50. How do you add multiple tabs to a JTabbedPane?
51. How can you set a custom icon for a tab in JTabbedPane?
52. How do you create a menu bar using JMenuBar in Swing?
53. Explain the purpose of JMenu, JMenuItem, and JSeparator.
54. What is the difference between JOptionPane.showMessageDialog() and
JOptionPane.showConfirmDialog()?
55. How do you create a modal dialog in Swing?
56. Explain the use of JFileChooser in Swing.
57. How do you load and display an image in Swing using ImageIcon?
58. What is the difference between BufferedImage and ImageIcon?
59. How do you scale an image in Swing without losing quality?
60. How do you set an image as a background in a JPanel?
61. What is JFrame in Swing?
62. How do you create a simple JFrame in Java?
63. What is JPanel in Swing?
64. What is the difference between JFrame and JPanel?
65. How do you add a JPanel to a JFrame?
66. How do you set the size of a JFrame?
67. What method is used to close a JFrame when the user clicks the close button?
68. What is the purpose of setVisible(true) in a Swing application?
69. What is the default layout of JFrame?
70. How do you handle events in Swing applications?
71. What is Java Database Connectivity (JDBC)?
72. Why is JDBC important in Java applications?
73. What are the main components of JDBC?
74. Explain the architecture of JDBC.
75. What are the different types of JDBC drivers?
76. How does JDBC establish a connection to a database?
77. What is a database URL in JDBC?
78. What is DriverManager in JDBC?
79. What is a Connection in JDBC?
80. How do you load a JDBC driver in Java?
81. How does JDBC interact with different database management systems (DBMS)?
82. What is a JDBC Driver?
83. What is DriverManager in JDBC?
84. How does DriverManager.getConnection() work?
85. What is a Connection in JDBC?
86. How do you create a Connection in JDBC?
87. What are the common methods available in the Connection interface?
88. What is a Statement in JDBC?
89. How do you execute a SQL query using a Statement?
90. What is the difference between Statement and PreparedStatement?
91. What are the advantages of using PreparedStatement over Statement?
92. What are the differences between executeQuery(), executeUpdate(), and execute()?
93. What is ResultSet in JDBC?
94. How do you retrieve data from a ResultSet?
95. How can you navigate a ResultSet forward and backward?
96. What are JDBC data types?
97. What is the role of Blob and Clob in JDBC?
98. How do you insert and retrieve dates using JDBC?
99. How do you update data in a database using JDBC?
100. What is a servlet in Java?
101. What are the advantages of using servlets over CGI?
102. Explain the architecture of a servlet-based web application.
103. What is the role of a web container in servlet execution?
104. How do you configure a servlet in a web application?
105. What is the web.xml file in a servlet application?
106. What are the different stages of the servlet life cycle?
107. Explain the role of the init() method in the servlet life cycle.
108. What is the purpose of the service() method in a servlet?
109. What happens when a servlet is destroyed?
110. What are the different methods available in the HttpServlet class?
111. What is the difference between doGet() and doPost() methods?
112. How do you read request parameters in a servlet?
113. How do you set response headers in a servlet?
114. What is an HTTP request?
115. How do you handle an HTTP GET request in a servlet?
116. How do you handle an HTTP POST request in a servlet?
117. What are the differences between GET and POST methods?
118. How do you retrieve form data sent via GET in a servlet?
119. How do you retrieve form data sent via POST in a servlet?
120. What is the HttpServletRequest object used for?
121. How do you send an HTTP response using a servlet?
122. What is the purpose of HttpServletResponse?
123. What is RequestDispatcher in Java servlets?
124. How do you forward a request using RequestDispatcher?
125. What is the difference between forward() and include() in RequestDispatcher?
126. What is the purpose of the sendRedirect() method?
127. What are the differences between RequestDispatcher and sendRedirect()?
128. When should you use forward() over sendRedirect()?
129. What are the disadvantages of using sendRedirect()?
130. How do you pass parameters when using RequestDispatcher?
131. What is a cookie in Java servlets?
132. How do you create a cookie in a servlet?
133. How do you retrieve cookies from an HTTP request?
134. What are the different attributes of a cookie?
135. How do you delete a cookie in Java servlets?
136. What are the limitations of cookies in session management?
137. How does a browser store and send cookies with requests?
138. What is the difference between a session cookie and a persistent cookie?
139. How do you set the expiration time for a cookie?
140. What is session tracking in servlets?
141. How do you use HttpSession for session management?
142. How do you create and retrieve a session object in servlets?
143. What are the different methods available in HttpSession?
144. How do you invalidate a session in a servlet?
145. What is the difference between getSession(true) and getSession(false)?
146. How do you set session timeout in Java servlets?