Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

3 simple servlet test questions

 
Stephen Lim
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
These are not taken from any certified exams, but belonging to a assessment test for registration purpose.
Can you guys pls let me know what are the answers or them? (I find the questions to be simple yet not precise per the Servlet APIs)
QUESTIONS: -
1. Which corresponding method in the HttpServlet class do you use to retrieve the value of a text field on an HTML form?

A. doPost

B. getParameter(String fieldName)

C. getHTTP(String fieldName)

D. doGet(String fieldName

2. What causes a servlet to load (2 options, choose the simplest/least operational impact)

A. A Web server start

B. The container detects that a class file has changed.

C. It is configured to do so periodically

D. It is loaded upon every request

3. Which interface defines the methods for retrieving form parameters

A. ServletRequest

B. ServletResponse

C. HTTPRequest

D. HTTPResponse
(This question seems to be quite funky as none of the options are 'interface' in the J2EE 1.3 APIs, right?)
 
Yuan Ye
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My answer would be 1.A 2.AC 3.A ( it is an interface).
 
Shishio San
Ranch Hand
Posts: 223
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. B
2. A,B (A: still it has to be configured in the web.xml to load at start-up)
3. A
Originally posted by Stephen Lim:

A. ServletRequest

B. ServletResponse

C. HTTPRequest

D. HTTPResponse
(This question seems to be quite funky as none of the options are 'interface' in the J2EE 1.3 APIs, right?)[/QB]

These are all interfaces.
 
francisk
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. A
Because it said HttpServlet class. If it said ServletRequest, I will pick B. getParameter()
2. A, B
When the deployment descriptor file have specified <load-on-startup>, it will load when web server start, otherwise it will load when the first request comming in.
3. A
 
Dani Mazzuca
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
definitively
1 - B
2 - A and B
3 - A (it is an interface)
Dani
 
Vedhas Pitkar
Ranch Hand
Posts: 445
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1.A
2.B,C
3.Should be HttpServletRequest
 
Amer Khan
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Methods for retrieving form parameters are defined in the ServletRequest interface(SR interface is implemented by the container).
 
Amer Khan
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A, tricky ? (There is no getParameter(String str) defined or inherited in HttpServlet class ,this method is defined in ServletRequest interface and is accessed through the HttpServletRequest object[interface HttpServletRequest extends interface ServletRequest )]NOTE:Both interfaces are implemented by the Container
B,C (<load-on-startup> in web.xml)
A, Methods for retrieving form parameters are defined in the ServletRequest interface(SR interface is implemented by the container).
[ August 05, 2003: Message edited by: Amer Khan ]
 
Meghasyam Bokam
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi moderator,
different people gave different answers. Can you please provide the right answers for the above questions.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic