108
86.9k
Chapter:

30+ Servlet and Overview Solved MCQs

in Advanced JAVA

These multiple-choice questions (MCQs) are designed to enhance your knowledge and understanding in the following areas: Master of Science in Information Technology (MSc IT) , Master of Science in Computer Science (MSc CS) , Bachelor of Business Administration in Computer Applications (BBA [CA]) , Programming Languages , Master of Science in Software Engineering (MSc SE) .

Chapters

Chapter: Servlet and Overview
1.

How is the dynamic interception of requests and responses to transform the information done?

A. servlet container
B. servlet config
C. servlet context
D. servlet filter
Answer» D. servlet filter
2.

Which type of ServletEngine is a server that includes built-in support for servlets?

A. Add-on ServletEngin
B. Embedded ServletEngine
C. Standalone ServletEngine
D. None of the above
Answer» C. Standalone ServletEngine
3.

What type of servlets use these methods doGet(), doPost(),doHead, doDelete(), doTrace()?

A. Genereic Servlets
B. HttpServlets
C. All of the above
D. None of the above
Answer» B. HttpServlets
4.

Which cookie it is valid for single session only and it is removed each time when the user closes the browser?

A. Persistent cookie
B. Non-persistent cookie
C. All the above
D. None of the above
Answer» B. Non-persistent cookie
5.

Sessions is a part of the SessionTracking and it is for maintaining the client state at server side.

A. True
B. False
C. none
D. all
Answer» A. True
6.

When destroy() method of a filter is called?

A. The destroy() method is called only once at the end of the life cycle of a filter
B. The destroy() method is called after the filter has executed doFilter method
C. The destroy() method is called only once at the begining of the life cycle of a filter
D. The destroyer() method is called after the filter has executed
Answer» A. The destroy() method is called only once at the end of the life cycle of a filter
7.

Web server is used for loading the init() method of servlet.

A. True
B. False
C. none
D. all
Answer» A. True
8.

Servlets handle multiple simultaneous requests by using threads.

A. True
B. False
C. none
D. all
Answer» A. True
9.

Which method is used to send the same request and response objects to another servlet in RequestDispacher ?

A. forward()
B. sendRedirect()
C. Both A & B
D. None of the above
Answer» A. forward()
10.

The sendRedirect() method of HttpServletResponse interface can be used to redirect response to another resource, it may be servlet, jsp or html file

A. True
B. False
C. none
D. all
Answer» A. True
11.

Which packages represent interfaces and classes for servlet API?

A. javax.servlet
B. javax.servlet.http
C. Both A & B
D. None of the above
Answer» C. Both A & B
12.

Which class can handle any type of request so that it is protocol-independent?

A. GenericServlet
B. HttpServle
C. Both A & B
D. None of the above
Answer» A. GenericServlet
13.

Which HTTP Request method is non-idempotent?

A. GET
B. POST
C. Both A & B
D. None of the above
Answer» C. Both A & B
14.

Which object is created by the web container at time of deploying the project?

A. ServletConfig
B. ServletContext
C. Both A & B
D. None of the above
Answer» B. ServletContext
15.

What is the lifecycle of a servlet?

A. Servlet class is loaded
B. Servlet instance is created
C. init,Service,destroy method is invoked
D. All mentioned above
Answer» D. All mentioned above
16.

Which method in session tracking is used in a bit of information that is sent by a web server to a browser and which can later be read back from that browser?

A. HttpSession
B. URL rewriting
C. Cookies
D. Hidden form fields
Answer» C. Cookies
17.

Which are the examples of Application Server?

A. Apache
B. Tomcat
C. JBoss
D. Weblogic
Answer» C. JBoss
18.

How many techniques are used in Session Tracking?

A. 4
B. 3
C. 2
D. 5
Answer» A. 4
19.

In HTTP Request method Get request is secured because data is exposed in URL bar

A. True
B. False
C. none
D. all
Answer» B. False
20.

In the following statements identify the disadvantages of CGI?

A. If number of clients increases, it takes more time for sending response
B. For each request, it starts a process and Web server is limited to start processes
C. It uses platform dependent language e.g. C, C++, perl
D. All mentioned above
Answer» D. All mentioned above
21.

Servlet technology is used to create web application

A. True
B. False
C. none
D. all
Answer» A. True
22.

Which method is used to specify before any lines that uses the PintWriter?

A. setPageType()
B. setContextType()
C. setContentType()
D. setResponseType()
Answer» C. setContentType()
23.

What are functions of Servlet container?

A. Lifecycle management
B. Communication Support
C. Multithreading Support
D. All of the above
Answer» D. All of the above
24.

Which object of HttpSession can be used to view and manipulate information about a session?

A. session identifier
B. creation time
C. last accessed time
D. All mentioned above
Answer» D. All mentioned above
25.

Which methods are used to bind the objects on HttpSession instance and get the objects?

A. setAttribute
B. getAttribute
C. Both A & B
D. None of the above
Answer» C. Both A & B
26.

Which method take a string not a URL?

A. sendRedirect
B. forward
C. Both
D. None
Answer» A. sendRedirect
27.

Which of the following are interface?
1. ServletContext
2. Servlet
3. GenericServlet
4. HttpServlet

A. 1,2,3,4
B. 1,2
C. 1,2,3
D. 1,4
Answer» B. 1,2
28.

The life cycle of a servlet is managed by

A. servlet context
B. servlet container
C. the supporting protocol (such as http or https)
D. All of the above
Answer» B. servlet container
29.

Which of the following code is used to get an attribute in a HTTP Session object in servlets?

A. session.getAttribute(String name)
B. session.alterAttribute(String name)
C. session.updateAttribute(String name)
D. session.setAttribute(String name)
Answer» A. session.getAttribute(String name)
30.

What is the difference between servlets and applets? i. Servlets execute on Server; Applets execute on browser ii. Servlets have no GUI; Applet has GUI iii. Servlets creates static web pages; Applets creates dynamic web pages iv. Servlets can handle only a single request; Applet can handle multiple requests

A. i, ii, iii are correct
B. i, ii are correct
C. i, iii are correct
D. i, ii, iii, iv are correct
Answer» B. i, ii are correct
31.

Which are the session tracking techniques? i. URL rewriting ii. Using session object iii.Using response object iv. Using hidden fields v. Using cookies vi. Using servlet object

A. i, ii, iii, vi
B. i, ii, iv, v
C. i, vi, iii, v
D. i, ii, iii, v
Answer» B. i, ii, iv, v
32.

A deployment descriptor describes

A. Web component response settings
B. Web component setting
C. Web component request objects
D. All of the above
Answer» B. Web component setting
33.

The values of <servlet-name> and <servlet-class> in web.xml file

A. must be same
B. must not be same
C. may be same
D. None of the above
Answer» C. may be same

Done Studing? Take A Test.

Great job completing your study session! Now it's time to put your knowledge to the test. Challenge yourself, see how much you've learned, and identify areas for improvement. Don’t worry, this is all part of the journey to mastery. Ready for the next step? Take a quiz to solidify what you've just studied.