Page: 8
Unit-1: The Servlet Technology Model
Q40. Choose the servlet code fragment that gets a binary stream for writing an image or other binary type to the HttpServletResponse. A. java.io.printWriter out = response.getWriter( ); B. ServletOutputStream out = response.getOutputStream( ); C. java.io.PrintWriter out = new PrintWriter(response.getWriter ( )); D. ServletOutputStream out = response.getBinaryStream( ); Option a is incorrect because it uses a character orented PrintWriter Q41.Which methods are used by a servlet to handle from data form a client?
[Choose all that apply] A. HttpServlet.doHead( ) B. HttpServlet.doPost( ) C. HttpServlet.doForm( ) D. ServletRequest.doGet( ) E. ServletRequest.doPost( ) F. ServletRequest.doForm( ) Q42. Which of the following methods are declared in HttpServletRequest as opposed ServletRequest? [Choose all that apply.] A. getMethod( ) B. getHeader( ) C. getCookies( ) D. getInputStream( ) E. getParameterNames( ) Options A,B and C all relate to components of an HTTP request. Q43. How should servlet developers handle the HttpServlet’s service ( ) method when extending HttpServlet? [Choose all that apply] A. They should override the service( ) method in most cases. B. They should call the service( ) method from doGet( ) or doPost( ) C. They should call the service( ) method from the init ( ) method. D. They should override at least one doXxx( ) method (such as doPost ( ) ) Option D is correct developers typically focus on the doGet ( ), and doPost( ) methods
Get Answers For All Questions
Page: 8
1
2
3
4
5
6
7
8
9
|