β˜‘ MCQ PRACTICE

Web Technologies Unit 3

Practice objective questions for quick revision and examination preparation. Try answering each question before revealing the answer.

πŸ“š Web Technologies
πŸ“– Unit 3
🎯 MCQs
Web Technologies MCQs - Unit 3

Web Technologies MCQs - Unit 3

1

How constructor can be used for a servlet?

A Initialization
B Contructor function
C Initialization and Contructor function
D Setup() method
Correct Answer C
2

Can servlet class declare constructor with ServletConfig object as a argument?

A True
B False
C True and False
D None of the above
Correct Answer B
3

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
Correct Answer B
4

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)
Correct Answer A
5

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()
Correct Answer A
6

Which of the following code retrieves the body of the request as binary data?

A DataInputStream data = new InputStream()
B DataInputStream data = response.getInputStream()
C DataInputStream data = request.getInputStream()
D DataInputStream data = request.fetchInputStream()
Correct Answer C
7

When destroy() method of 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 Both of the mentioned
D The destroyer() method is called after the filter has executed
Correct Answer A
8

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
Correct Answer D
9

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

A servlet container
B servlet config
C servlet context
D servlet filter
Correct Answer D
10

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
Correct Answer B
11

Which of the following is the correct order of servlet life cycle phase methods?

A init(), service(), destroy()
B initialize(), service(), destroy()
C init(), execute(), destroy()
D init(), service(), delete()
Correct Answer A
12

Which of the following is true about HTTP Get method?

A The GET method sends the encoded user information appended to the page request.
B The GET method is the defualt method to pass information from browser to web server.
C Both of the above.
D None of the above.
Correct Answer C
13

Which of the following code is used to get names of the attributes in servlet?

A response.getAttributeNames()
B request.getAttributeNames()
C Header.getAttributeNames()
D None of the above.
Correct Answer B
14

Which of the following code retrieves the request header?

A Header.getHeaderName(headerName)
B response.getHeader(headerName)()
C request.getHeader(headerName)
D None of the above.
Correct Answer C
15

Which of the following code encodes the specified URL for use in the sendRedirect method?

A response.encodeRedirectURL(url)
B request.encodeRedirectURL(url)
C Header.encodeRedirectURL(url)
D None of the above.
Correct Answer A
16

Which of the following code can be used to add a header?

A request.addHeader(name,value)
B response.addDateHeader(name,value)
C Header.addDateHeader(name,value)
D None of the above.
Correct Answer B
17

When init() method of filter gets called?

A The init() method is called by the web container to indicate to a filter that it is being placed into service.
B The init() method is called whenever the servlet being filtered is invoked.
C Both of the above.
D None of the above.
Correct Answer A
18

Which of the following is true about javax.servlet.error.status_code?

A This attribute gives exact error message which can be stored and analysed after storing in a java.lang.String data type.
B This attribute gives information about exception type which can be stored and analysed after storing in a java.lang.Class data type.
C This attribute gives status code which can be stored and analysed after storing in a java.lang.Integer data type.
D This attribute gives information about URL calling the servlet and it can be stored and analysed after storing in a java.lang.String data type.
Correct Answer C
19

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

A session.setAttribute(name,value)
B session.alterAttribute(name,value)
C session.updateAttribute(name,value)
D None of the above.
Correct Answer A
20

Which of the following code is used to delete an attribute from a HTTP

A Session object in servlets?
B session.removeAttribute(name)
C session.alterAttribute(name)
D session.updateAttribute(name)
Correct Answer A
← Back to All MCQs