Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JavaRanch MockExamQuestion

 
Divya Guttikonda
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is a Mock Exam Question from JavaRanch:

A client types the URI :
http://www.someserver.com/servlet/SomeServlet?name=fred
The value of name can be obtained by:

a)doGet(HttpServletRequest request, HttpServletResponse response)
{
String name = response.getParameter("name");
...


b) service(HttpServletRequest request, HttpServletResponse response)
{
String name = request.getParameter("name");
...


c)doGet(HttpServletRequest request, HttpServletResponse response)
{
String name = request.getInitParameter("name");
...


d)doGet(HttpServletRequest request, HttpServletResponse response)
{
String name = request.getParameter("name");
...

The answer given is b, but i think the correct answer is d.Can anybody help me with this?

Thanks
Divya.
 
Sirisha Reddy
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i dont see why d is not correct answer ?!
 
shiva viswanathan
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey I think both b and d are correct answers since ultimately the service method calls the doGet method passing the same HttpServletRequest
method
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!