Advanced Programming2019
Advanced Programming2019
23. When we are sending data in URL in get method, how to separate parameters?
a. By comma
b. By semicolon
c. By question mark
d. By ampersand
24. Which http method send by browser that asks the server to get the page only?
a. Get
b. Post
c. Option
d. Put
25. Which of the following interprets html code and renders webpages to users?
a. Browser
b. Client
c. Server
d. None of the above
26. Which http method send by browser that gives the server what user data typed in the
form?
a. Put
b. Post
c. Delete
d. None of the above
3
29. Which tag does not belong to web.xml?
a. Web-app
b. Welcome-file-list
c. Servlet
d. Servlet-mappings
4
37. For a given ServletResponse response, which retrieve an object for writing text data?
(A) response.getOutputWriter()
(B) response.getWriter()
(C) response.getWriter().getOutputStream()
(D) response.getWriter(Writer.OUTPUT_TEXT)
38. Given:
1. public void service(ServletRequest request,
2. ServletResponse response) {
3. ServletInputStream sis =
4. // insert code here
5. }
Which retrieves the binary input stream on line 4 ?
(A) request.getReader();
(B) request.getWriter();
(C) request.getResourceAsStream();
(D) request.getInputStream();
39. Given the following servlet mapping definition for the web application named
'secureapp',
<servlet>
<servlet-name>ProcessLoginData</servlet-name>
<servlet-class>DoLogin</servlet-class>
<servlet/>
<servlet-mapping>
<servlet-name>ProcessLoginData</servlet-name>
<url-pattern>do/Login</url-pattern>
<servlet-mapping/>
Which of the following URLs will correctly request the Servlet?
(A) http://www.mywebapp.com/secureapp/do/Login?name="bob"
(B) http://www.mywebapp.com/secureapp/doLogin?name="bob"
(C) http://www.mywebapp.com/Login?name="bob"
(D) http://www.mywebapp.com/secureapp/Login?name="bob"
40. The method getWriter returns an object of type PrintWriter. This class has println
methods to generate output. Which of these classes define the getWriter method? Select
the one correct answer.
(A) HttpServletRequest
(B) ServletConfig
(C) HttpServletResponse
(D) ServletContext
41. Name the method defined in the HttpServletResponse class that may be used to set the
content type. Select the one correct answer.
(A) setContent
(B) setType
(C) setContentType
(D) setResponseContentType
Ques 14 :
42. In which file do we define a servlet mapping?
(A) servlet.mappings
(B) servlet.xml
(C) web.xml
5
(D) Simple.java
43. You are creating a servlet that generates stock market graphs. You want to provide the
web browser with precise information about the amount of data being sent in the
response stream.
Which HttpServletResponse methods will you use to provide this information?
(A) response.setLength(numberOfBytes);
(B) response.setContentLength(numberOfBytes);
(C) response.setHeader("Length", numberOfBytes);
(D) response.setIntHeader("Length", numberOfBytes);
44. You need to create a servlet filter that stores all request headers to a database for all
requests to the web application's home page "/index.jsp". Which HttpServletRequest
method allows you to retrieve all of the request headers?
(A) java.util.Iterator getRequestHeaders()
(B) java.util.Enumeration getHeaderNames()
(C) java.util.Iterator getHeaderNames()
(D) String[] getRequestHeaders()
46. 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)
47. Which method is used to specify before any lines that uses the PintWriter?
A. setPageType()
B. setContextType()
C. setContentType()
D. setResponseType()
48. 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
49. 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
50. Which method take a string not a URL?
6
A. sendRedirect
B. forward
C. Both
D. None