JavaQuizzes

Quiz Guidelines

 

Multiple Choice Question

QID: 
6

Given an HttpServletRequest request and HttpResponse response, which sets a cookie “username” with the value “john” in a servlet?

A. request.addCookie("username", "john")
B. request.setCookie("username", "john")
C. response.addCookie("username", "john")
D. request.addHeader(new Cookie("username", "john"))
E. request.addCookie(new Cookie("username", "john"))
F. response.addCookie(new Cookie("username", "john"))
G. response.addHeader(new Cookie("username", "john"))

Multiple Choice Question

QID: 
7

Which annotation enables a servlet to efficiently process requests of typo multipart/form-data that
involve large files being uploaded by the client?
A. @AcceptMultipart
B. @MultiPartConfig
C. @MultiPartFormData
D. @WebServlet (multipart = true

Multiple Choice Question

QID: 
8

How can you ensure that data is updated in a thread safe manner without using singieThreadModel?

Select 2
A. Store the data in a local variable.
B. Store the data in an instance variable.
C. Store the data in the Httpsession object.
D. Store the data in the sarvletContext object.
E. Store the data in the ServletRequest object.

Multiple Choice Question

QID: 
9

Given an HttpServletRequest request and an httpServletResponse response:

HttpSession session = null;
/ / insert code here
if (session = = null) {
/ / do something if session does not exist
} else {
/ / do something if session exists
}

Which of the code below is more appropriate to be inserted instead of the line that contains '/ / insert code here' ?

A. session = response.getSession ();
B. session = request.getSession ();
C. session = request.getSession (true);
D. session = request.getSession (false);
E. session = request.getSession (“jsessionid”);
 

Multiple Choice Question

QID: 
10

Which interface must a class implement so that instances of the class are notified after any object added to a session?
A. javax.servlet.http.HttpSessionListener
B. javax.servlet.http.HttpSessionValueListener
C. javax.servlet.http.HttpSessionBindingListener
D. javax.servlet.http.HttpSessionAttributeListener

Pages

Search the Web

Custom Search

Searches whole web. Use the search in the right sidebar to search only within javajee.com!!!