• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Doubts in mocks

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, can you quote your source ?
 
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic