0% found this document useful (0 votes)
109 views8 pages

Department of Computer Science and Engineering: Unit III - MCQ Bank

1) Servlets execute within the address space of a web server, are platform independent because they are written in Java, and can use the full functionality of Java class libraries. 2) The document contains a multiple choice quiz on servlets and JSP concepts with questions about servlet lifecycle, request and response objects, sessions, and JSP tags. 3) It provides answers to 29 multiple choice questions testing knowledge of servlet and JSP fundamentals.

Uploaded by

Ramesh Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
109 views8 pages

Department of Computer Science and Engineering: Unit III - MCQ Bank

1) Servlets execute within the address space of a web server, are platform independent because they are written in Java, and can use the full functionality of Java class libraries. 2) The document contains a multiple choice quiz on servlets and JSP concepts with questions about servlet lifecycle, request and response objects, sessions, and JSP tags. 3) It provides answers to 29 multiple choice questions testing knowledge of servlet and JSP fundamentals.

Uploaded by

Ramesh Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

ChettinadTech Dept of CSE

Department of Computer Science and Engineering


CS8651 – INTERNET PROGRAMMING
Unit III - MCQ Bank
1. Which of the following is true about servlets?
a. Servlets execute within the address space of a Web server.
b. Servlets are platform-independent because they are written in Java.
c. The full functionality of the Java class libraries is available to a servlet.
d. All of the above.
Answer: d
2. Which of the following is true about destroy() method of servlet?
a. After the destroy() method is called, the servlet object is marked for garbage collection.
b. The servlet is terminated by calling the destroy() method.
c. Both of the above.
d. None of the above
Answer: c
3. Which of the following code is used to get names of the parameters in servlet?
a. request.getParameterNames()
b. response.getParameterNames()
c. Header.getParameterNames()
d. None of the above.
Answer: a
4. Which of the following code retrieves the context of the request?
a. new ClassContextPath()
b. request.getContextPath()
c. response.getContextPath()
d. None of the above.
CS8651 – INTERNET PROGRAMMING Page 1
ChettinadTech Dept of CSE

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()

CS8651 – INTERNET PROGRAMMING Page 2


ChettinadTech Dept of CSE

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()

CS8651 – INTERNET PROGRAMMING Page 3


ChettinadTech Dept of CSE

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

CS8651 – INTERNET PROGRAMMING Page 4


ChettinadTech Dept of CSE

b. rdb and javax.rdb


c. jdbc and java.jdbc.sql
d. sql and javax.sql
Answer: d
18. What is the correct sequence to create a database connection?
i. Import JDBC packages.
ii. Open a connection to the database.
iii. Load and register the JDBC driver.
iv. Execute the statement object and return a query resultset.
v. Create a statement object to perform a query.
vi. Close the resultset and statement objects.
vii. Process the resultset.
viii. Close the connection.
a. i, ii, iii, v, iv, vii, viii, vi
b. i, iii, ii, v, iv, vii, vi, viii
c. ii, i, iii, iv, viii, vii, v, vi
d. i, iii, ii, iv, v, vi, vii, viii
Answer: b
19. Which of the following method is static and synchronized in JDBC API?
a. getConnection()
b. prepareCall()
c. executeUpdate()
d. executeQuery()
Answer: a
20. Which of the following is not a valid statement in JDBC?
a. Statement
b. PreparedStatement
c. QueryStatement
d. CallableStatement

CS8651 – INTERNET PROGRAMMING Page 5


ChettinadTech Dept of CSE

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.

CS8651 – INTERNET PROGRAMMING Page 6


ChettinadTech Dept of CSE

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

CS8651 – INTERNET PROGRAMMING Page 7


ChettinadTech Dept of CSE

30. Which is not a directive?


a. include
b. page
c. xport
d. useBean
Answer: c

CS8651 – INTERNET PROGRAMMING Page 8

You might also like