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?
AInitialization
BContructor function
CInitialization and Contructor function
DSetup() method
Correct AnswerC
2
Can servlet class declare constructor with ServletConfig object as a argument?
ATrue
BFalse
CTrue and False
DNone of the above
Correct AnswerB
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
Ai,ii,iii are correct
Bi,ii are correct
Ci,iii are correct
Di,ii,iii,iv are correct
Correct AnswerB
4
Which of the following code is used to get an attribute in a HTTP Session object in servlets?
Asession.getAttribute(String name)
Bsession.alterAttribute(String name)
Csession.updateAttribute(String name)
Dsession.setAttribute(String name)
Correct AnswerA
5
Which method is used to get three-letter abbreviation for localeβs country in servlets?
ARequest.getISO3Country()
BLocale.getISO3Country()
CResponse.getISO3Country()
DLocal.retrieveISO3Country()
Correct AnswerA
6
Which of the following code retrieves the body of the request as binary data?
ADataInputStream data = new InputStream()
BDataInputStream data = response.getInputStream()
CDataInputStream data = request.getInputStream()
DDataInputStream data = request.fetchInputStream()
Correct AnswerC
7
When destroy() method of filter is called?
AThe destroy() method is called only once at the end of the life cycle of a filter
BThe destroy() method is called after the filter has executed doFilter method
CBoth of the mentioned
DThe destroyer() method is called after the filter has executed
Correct AnswerA
8
Which of the following is true about servlets?
AServlets execute within the address space of web server
BServlets are platform-independent because they are written in java
CServlets can use the full functionality of the Java class libraries
DServlets execute within the address space of web server, platform independent and uses the functionality of java class libraries
Correct AnswerD
9
How is dynamic interception of requests and responses to transform the information done?
Aservlet container
Bservlet config
Cservlet context
Dservlet filter
Correct AnswerD
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
Ai, ii, iii, vi
Bi, ii, iv, v
Ci, vi, iii, v
Di, ii, iii, v
Correct AnswerB
11
Which of the following is the correct order of servlet life cycle phase methods?
Ainit(), service(), destroy()
Binitialize(), service(), destroy()
Cinit(), execute(), destroy()
Dinit(), service(), delete()
Correct AnswerA
12
Which of the following is true about HTTP Get method?
AThe GET method sends the encoded user information appended to the page request.
BThe GET method is the defualt method to pass information from browser to web server.
CBoth of the above.
DNone of the above.
Correct AnswerC
13
Which of the following code is used to get names of the attributes in servlet?
Aresponse.getAttributeNames()
Brequest.getAttributeNames()
CHeader.getAttributeNames()
DNone of the above.
Correct AnswerB
14
Which of the following code retrieves the request header?
AHeader.getHeaderName(headerName)
Bresponse.getHeader(headerName)()
Crequest.getHeader(headerName)
DNone of the above.
Correct AnswerC
15
Which of the following code encodes the specified URL for use in the sendRedirect method?
Aresponse.encodeRedirectURL(url)
Brequest.encodeRedirectURL(url)
CHeader.encodeRedirectURL(url)
DNone of the above.
Correct AnswerA
16
Which of the following code can be used to add a header?
Arequest.addHeader(name,value)
Bresponse.addDateHeader(name,value)
CHeader.addDateHeader(name,value)
DNone of the above.
Correct AnswerB
17
When init() method of filter gets called?
AThe init() method is called by the web container to indicate to a filter that it is being placed into service.
BThe init() method is called whenever the servlet being filtered is invoked.
CBoth of the above.
DNone of the above.
Correct AnswerA
18
Which of the following is true about javax.servlet.error.status_code?
AThis attribute gives exact error message which can be stored and analysed after storing in a java.lang.String data type.
BThis attribute gives information about exception type which can be stored and analysed after storing in a java.lang.Class data type.
CThis attribute gives status code which can be stored and analysed after storing in a java.lang.Integer data type.
DThis 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 AnswerC
19
Which of the following code is used to update an attribute in a HTTP Session object in servlets?
Asession.setAttribute(name,value)
Bsession.alterAttribute(name,value)
Csession.updateAttribute(name,value)
DNone of the above.
Correct AnswerA
20
Which of the following code is used to delete an attribute from a HTTP