Department of Computer Science and Engineering: Unit III - MCQ Bank
Department of Computer Science and Engineering: Unit III - MCQ Bank
Answer: b
5. Which of the following code checks whether this request was made using a secure channel, such
as HTTPS?
a. response.isSecure()
b. request.isSafe()
c. Header.isSecure()
d. None of the above.
Answer: b
6. Which of the following code can be used to write a cookie?
a. request.addCookie(cookie)
b. response.addCookie(cookie)
c. Header.addCookie(cookie)
d. None of the above.
Answer: b
7. Which of the following code can be used to set the length of content of body of the response?
a. request.setContentLength(length)
b. response.setContentLength(length)
c. header.setContentLength(length)
d. None of the above.
Answer: b
8. How to create a cookie in servlet?
a. Use new operator.
b. Use request.getCookie() method
c. Use response.getCookie() method
d. None of the above
Answer: a
9. Which of the following code is used to delete a HTTP Session object in servlets?
a. session.invalidate()
b. response.deleteSession()
c. request.deleteSession()
d. None of the above.
Answer: a
10. How constructor can be used for a servlet?
a. Initialization
b. Constructor function
c. Initialization and Constructor function
d. Setup() method
Answer: c
11. 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
12. 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
13. Which method is used to get three-letter abbreviation for locale’s country in servlets?
a. Request.getISO3Country()
b. Locale.getISO3Country()
c. Response.getISO3Country()
d. Local.retrieveISO3Country()
Answer: a
14. Which of the following is true about servlets?
a. Servlets execute within the address space of web server
b. Servlets are platform-independent because they are written in java
c. Servlets can use the full functionality of the Java class libraries
d. Servlets execute within the address space of web server, platform independent and uses
the functionality of java class libraries
Answer: d
15. 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
16. What are the major components of the JDBC?
a. DriverManager, Driver, Connection, Statement, and ResultSet
b. DriverManager, Driver, Connection, and Statement
c. DriverManager, Statement, and ResultSet
d. DriverManager, Connection, Statement, and ResultSet
Answer: a
17. Select the packages in which JDBC classes are defined?
a. jdbc and javax.jdbc
Answer: c
21. What is the correct signature of _jspService() method of HttpJspPage class?
a. void _jspService(HTTPRequest request, HTTPResponse response)
b. void _jspService(HTTPRequest request, HTTPResponse response) throws
ServletException, IOException
c. void _jspService()
d. void _jspService() throws ServletException, IOException
Answer: b
22. Which of the following attributes are mandatory in <jsp:useBean /> tag?
a. id, type
b. id, class
c. type, class
d. type,property
Answer: b
23. Which of the following attributes are used in <jsp:include /> tag?
a. id, type
b. page, flush
c. type, class
d. type,page
Answer: b
24. pageContext is instance of which class?
a. javax.servlet.ServletContext
b. javax.servlet.ServletConfig
c. javax.servlet.jsp.PageContext
d. javax.servlet.Application
Answer: c
25. Which of the following is true about isELIgnored Attribute?
a. The isELIgnored option gives you the ability to disable the evaluation of scriplets.
b. The isELIgnored option gives you the ability to disable the evaluation of java code in jsp.
c. The isELIgnored option gives you the ability to disable the evaluation of Expression
Language (EL) expressions.
d. None of the above.
Answer: c
26. Which of the following step is taken by JSP container during Compilation phase?
a. Parsing the JSP.
b. Turning the JSP into a servlet.
c. Compiling the servlet.
d. All of the above.
Answer: c
27. Which of the following is true about <c:forEach > tag?
a. The <c:forEach > exists as a good alternative to embedding a Java for, while, or do-while
loop via a scriptlet.
b. The <c:forEach > is used to iterate over a list of items in jsp.
c. Both of the above.
d. None of the above.
Answer: c
28. Which option is true about session scope?
a. Objects are accessible only from the page in which they are created
b. Objects are accessible only from the pages which are in same session
c. Objects are accessible only from the pages which are processing the same request
d. Objects are accessible only from the pages which reside in same application
Answer: b
29. “request” is instance of which one of the following classes?
a. Request
b. HttpRequest
c. HttpServletRequest
d. ServletRequest
Answer: c