Learn. Practice. Feel prepared.
Servlet Objective Questions and Answers
Strengthen your understanding of Java Servlets with topic-wise multiple-choice questions covering Servlet lifecycle, request & response handling, sessions, cookies, filters, listeners, security, and deployment descriptors.
Practice Servlet MCQs with Detailed Explanations
Answer at least 12 questions to submit and verify answers.
1 What are the mechanisms available in ServletContextListener interface?
Correct answer:
contextInitialized((),contextDestroyed()
2 A deployment descriptor describes
Correct answer:
web component settings
3 Dynamic interception of requests and responses to transform the information is done by
Correct answer:
servlet filter
4 he life cycle of a servlet is managed by
Correct answer:
servlet container
5 The include() method of RequestDispatcher
Correct answer:
sends a request to another resource like servlet, jsp or html
6 The method forward(request,response) will
Correct answer:
return back to the same method from where the forward was invoked
7 What is the limit of data to be passed from HTML when doGet() method is used?
Correct answer:
2K
8 The getSession() method with 'true' as its parameter [ getSession(true) ] it will return the appropriate session object when
Correct answer:
the session is existing
9 Which of the following are the session tracking techniques?
Correct answer:
URL rewriting, using session object, using cookies, using hidden fields
10 In which advantage of servlet, Servlets are managed by JVM so no need to worry about memory leak, garbage collection etc.?
Correct answer:
Robust
11 In the following statements identify the disadvantages of CGI?
Correct answer:
All mentioned above
12 In HTTP Request Which Asks for the loopback of the request message, for testing or troubleshooting?
Correct answer:
TRACE
13 In RequestDispacher which method is used to sends the same request and response objects to another servlet?
Correct answer:
forward()
14 An object of Which is created by the web container at time of deploying the project?
Correct answer:
ServletContext
15 An attribute in servlet is an object that can be set, get or removed from one of the following scopes?
Correct answer:
All mentioned above