Skip to main content

Web Design and Development MCQs with Answers

Practice important Web Design and Development MCQs with answers and explanations.

Chapter: 27
Q421:
What is the standard file extension for a web application archive?
A. .jar
B. .zip
C. .war
D. .tar
Correct Answer: C
Chapter: 27
Q422:
What does the doGet() method in a servlet handle?
A. POST requests
B. PUT requests
C. GET requests
D. DELETE requests
Correct Answer: C
Chapter: 27
Q423:
Which package must be imported to use HttpServlet?
A. javax.servlet
B. javax.servlet.http
C. java.io
D. java.util
Correct Answer: B
Chapter: 27
Q424:
What is the default URL pattern for accessing a servlet named HelloWorldServlet as per the web.xml configuration?
A. /index.html
B. /hello
C. /myfirstservlet
D. /HelloWorldServlet
Correct Answer: C
Chapter: 27
Q425:
How are attribute-value pairs attached in a GET request?
A. Within the request body
B. After the URL with ?
C. In the headers
D. In the request path
Correct Answer: B
Chapter: 27
Q426:
Which HTTP request type is used to submit data to the server?
A. GET
B. POST
C. PUT
D. DELETE
Correct Answer: B
Chapter: 27
Q427:
How often should you restart Tomcat when adding new servlets or Java Beans?
A. Every time
B. Only for JSP files
C. Once a day
D. Once a week
Correct Answer: A
Chapter: 27
Q428:
What is the role of the web.xml file in a web application?
A. To compile servlets
B. To specify servlet mappings and configuration
C. To store JSP files
D. To create a directory structure
Correct Answer: B
Chapter: 27
Q429:
In which directory should you place your compiled servlet class files?
A. C:\jakarta-tomcat-5.5.9\webapps\myapp
B. C:\jakarta-tomcat-5.5.9\webapps\myapp\WEB-INF
C. C:\jakarta-tomcat-5.5.9\webapps\myapp\WEB-INF\classes
D. C:\jakarta-tomcat-5.5.9\webapps\myapp\lib
Correct Answer: C
Chapter: 27
Q430:
What does the doPost() method in a servlet handle?
A. GET requests
B. POST requests
C. PUT requests
D. DELETE requests
Correct Answer: B
Chapter: 27
Q431:
Which class should you extend if you want to write a protocol-independent servlet?
A. HttpServlet
B. GenericServlet
C. ServletRequest
D. ServletResponse
Correct Answer: B
Chapter: 27
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
Correct Answer: A
Chapter: 27
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
Correct Answer: C
Chapter: 27
Q434:
What should you use to generate HTTP responses in a servlet?
A. PrintWriter
B. ServletRequest
C. HttpServletRequest
D. ServletResponse
Correct Answer: A
Chapter: 27
Q435:
What does the lib folder in WEB-INF typically contain?
A. HTML files
B. Java source files
C. JAR files
D. Static resources
Correct Answer: C
Chapter: 28
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
Correct Answer: A
Chapter: 28
Q437:
Which method is called by default when you access a URL in a servlet?
A. doPost()
B. doGet()
C. init()
D. destroy()
Correct Answer: B
Chapter: 28
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
Correct Answer: B
Chapter: 28
Q439:
What is the first stage in the lifecycle of a servlet?
A. Initialize
B. Service
C. Destroy
D. Unload
Correct Answer: A
Chapter: 28
Q440:
Which method is invoked during the initialization stage of a servlet?
A. init()
B. doGet()
C. doPost()
D. destroy()
Correct Answer: A

Test Your Knowledge

Take a timed quiz on Web Design and Development

🚀 Start Quiz Now