• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubts in mocks

 
sri sun
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai friends

I am silent viewer of this forum.My exam is there within three days.I had no previous working experience.Actually I am doing some mockexams.In those I got some doubts.

Please carify my doubts

What is the output when you try to invoke the servlet defined below with the following URL from the address line from your browser:

http://localhost/servlet/com.baboon.scwcd.servletmodel.TestParamServlet?Param=10
package com.baboon.scwcd.servletmodel;
public class TestParamServlet extends HttpServlet {
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
resp.getWriter().println (req.getParameter("param"));
}
}
1 Code compiles, blank page is displayed with the value 10 printed out.
2 Code compiles, blank page is displayed.
3 Code compiles, blank page is displayed with the value null printed out.
4 Code fails compilation, exception NullPointerException not caught.
5 Code compiles, HTTP GET request not supported.


Acc to mock Ans is 5.But in HFSJ it will fail.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, can you quote your source ?
 
Dee Brown
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Answer "5" is correct because the browser will generate a GET request when the link is clicked, and doGet is not overridden. There does not appear to be any syntax errors, so the code should compile.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic