Web Design and Development MCQs with Answers
Practice important Web Design and Development MCQs with answers and explanations.
Multiple Choice Questions
Q431: Which class should you extend if you want to write a protocol-independent servlet?
- A: HttpServlet
- B: GenericServlet
- C: ServletRequest
- D: ServletResponse
View Answer
B
Q432: What must be done if you use a package for your servlet?
- A: Create a complete package structure under the classes folder
- B: Create a new directory in the lib folder
- C: Change the servlet mapping in web.xml
- D: Restart Tomcat server
View Answer
A
Q433: What does a servlet's deployment descriptor file (web.xml) contain?
- A: Servlet code
- B: HTML code
- C: Servlet configuration and mappings
- D: CSS code
View Answer
C
Q434: What should you use to generate HTTP responses in a servlet?
- A: PrintWriter
- B: ServletRequest
- C: HttpServletRequest
- D: ServletResponse
View Answer
A
Q435: What does the lib folder in WEB-INF typically contain?
- A: HTML files
- B: Java source files
- C: JAR files
- D: Static resources
View Answer
C
Q436: What is required to deploy a web application in Tomcat?
- A: Place files in the webapps folder
- B: Create a new directory structure
- C: Write Java code
- D: All of the above
View Answer
A
Q437: Which method is called by default when you access a URL in a servlet?
- A: doPost()
- B: doGet()
- C: init()
- D: destroy()
View Answer
B
Q438: Where do you place your HTML files for a web application?
- A: In the WEB-INF folder
- B: In the main application folder
- C: In the classes folder
- D: In the lib folder
View Answer
B
Q439: What is the first stage in the lifecycle of a servlet?
- A: Initialize
- B: Service
- C: Destroy
- D: Unload
View Answer
A
Q440: Which method is invoked during the initialization stage of a servlet?
- A: init()
- B: doGet()
- C: doPost()
- D: destroy()
View Answer
A