11.) What methods can you override in a Java Servlet to handle initialization and cleanup tasks?
A) init() and cleanup()
B) initialize() and finalize()
C) init() and destroy()
D) startup() and shutdown()
12.) In modern Java EE applications (Servlet 3.0+), what is the preferred way to configure Servlets and URL mappings?
A) In the web.xml deployment descriptor.
B) Using XML configuration files.
C) Through annotations.
D) In a separate properties file.
13.) What is a WAR file in the context of Java Servlets?
A) A file format for audio data.
B) A web archive file containing Servlets, JSPs, and other web resources.
C) A Java class file.
D) A web server configuration file.
14.) What is the purpose of JavaServer Pages (JSP) in relation to Java Servlets?
A) To define URL patterns.
B) To handle HTTP requests.
C) To create dynamic web pages by embedding Java code within HTML templates.
D) To manage client sessions.
15.) Which method is used to send data from a Servlet to the client’s web browser?
A) getWriter()
B) read()
C) doOutput()
D) sendResponse()
16.) What does the web.xml file typically contain in a Java web application?
A) Servlet code.
B) JSP templates.
C) Deployment configuration, including Servlet mappings.
D) HTML content.
17.) What is the role of the init() method in a Java Servlet?
A) Handling HTTP requests.
B) Cleaning up resources.
C) Initializing the Servlet when it is first loaded.
D) Managing client sessions.
18.) What is the purpose of a Servlet filter chain?
A) To process requests and responses in a specific order.
B) To handle database operations.
C) To define URL patterns.
D) To create HTML templates.
19.) What is the primary function of the HttpSession object in a Java Servlet?
A) Handling database connections.
B) Representing the HTTP request.
C) Managing client sessions and storing session data.
D) Generating HTML content.
20.) Which annotation is used to specify a URL pattern for a Servlet class in modern Java EE applications?
A) @Pattern
B) @Url
C) @RequestMapping
D) @WebServlet