| ADVANCE JAVA (3360701) |
212) Request is instance of which class?
A. Request
B. HttpRequest
C. HttpServletRequest
D. ServletRequest
Answer : C
213) Session is instance of which class?
A. Session
B. HttpSession
C. HttpServletSession
D. ServletSession
Answer : B
214) Which of the following is not a implicit object?
A. Request
B. Response
C. Cookie
D. Session
Answer : C
215) Which of the following is true about service () method of servlet?
A. The servlet container (i.e. web server) calls the service () method to handle requests coming from the client.
B. Each time the server receives a request for a servlet; the server spawns a new thread and calls service.
C. The service () method checks the HTTP request type (GET, POST, PUT, DELETE, etc.) and calls doGet, doPost, doPut, doDelete, etc. methods as appropriate.
D. All of the above.
Answer : D
216) When service () method of servlet gets called?
A. The service () method is called when the servlet is first created.
B. The service () method is called whenever the servlet is invoked.
C. Both of the above.
D. None of the above.
Answer : B
217) Which of the following is true about init() method of servlet?
A. The init() method simply creates or loads some data that will be used throughout the life of the servlet.
B. The init() method is not called again and again for each user request.
C. Both of the above.
D. None of the above.
Answer : C
218) When init() method of servlet gets called?
A. The init() method is called when the servlet is first created.
B. The init() method is called whenever the servlet is invoked.
C. Both of the above.
D. None of the above.
Answer : A
219) Which of the following is the correct order of servlet life cycle phase methods?
A. init(), service(), destroy()
B. initialize(), service(), destroy()
C. init(), execute(), destroy()
D. init(), service(), delete()
Answer : A
220) Which of the following package contains servlet classes?
A. javax.servlet
B. javax.servlet.http
C. Both of the above.
D. None of the above.
Answer: C
221) Which of the following is true about servlets?
A. Servlets execute within the address space of a Web server.
B. Servlets are platform-independent because they are written in Java.
C. The full functionality of the Java class libraries is available to a servlet.
D. All of the above.
Answer : D
222) What are Servlets?
A. Java Servlets are programs that run on a Web or Application server.
B. Java Servlets act as a middle layer between a requests coming from a Web browser or other HTTP client and databases or applications on the HTTP server.
C. Both of the above.
D. None of the above.
Answer : C
223) Which of the following code is used to get names of the attributes in servlet?
A. response.getAttributeNames()
B. request.getAttributeNames()
C. Header.getAttributeNames()
D. None of the above.
Answer : C
224) Which of the following code is used to get cookies in servlet?
A. response.getCookies()
B. request.getCookies()
C. Cookies.getCookies()
D. None of the above.
Answer : B
225) Which of the following is true about HTTP Get method?
A. The GET method sends the encoded user information appended to the page request.
B. The GET method is the default method to pass information from browser to web server.
C. Both of the above.
D. None of the above.
Answer : C
226) Which of the following is true about HTTP Post method?
A. The POST method sends the encoded user information as a separate message to page request.
B. The POST method is used to submit form data normally.
C. Both of the above.
D. None of the above.
Answer : C
227) Which of the following method can be used to get the value of form parameter?
A. request.getParameter()
B. request.getParameterValues()
C. request.getParameterNames()
D. None of the above.
Answer : A
228) Which of the following method can be used to get complete list of all parameters in the current request?
A. request.getParameter()
B. request.getParameterValues()
C. request.getParameterNames()
D. None of the above.
Answer : C
229) Which of the following method can be used to get the multiple values of a parameter like checkbox data?
A. request.getParameter ()
B. request.getParameterValues()
C. request.getParameterNames()
D. None of the above.
Answer : B
230)What is Javax.servlet.http.HttpServlet?
A. Interface
B. Abstract class
C. Concreate class
D. None of the above
Answer : B
231) What is javax.servlet.Servlet?
A. Interface
B. Abstract class
C. Concrete class
D. None of the above.
Answer : A
232) Which of the following is true about destroy () method of servlet?
A. After the destroy () method is called, the servlet object is marked for garbage collection.
B. The servlet is terminated by calling the destroy () method.
C. Both of the above.
D. None of the above.
Answer : C
233) When destroy () method of servlet gets called?
A. The destroy () method is called only once at the end of the life cycle of a servlet.
B. The destroy () method is called after the servlet has executed service method.
C. Both of the above.
D. None of the above.
Answer : A
234) When doPost () method of servlet gets called?
A. A POST request results from an HTML form that specifically lists POST as the METHOD.
B. The service () method checks the HTTP request type as POST and calls doPost() method.
C. Both of the above.
D. None of the above.
Answer : C
235) When doGet () method of servlet gets called?
A. A GET request results from a normal request for a URL.
B. The service () method checks the HTTP request type as GET and calls doGet() method.
C. Both of the above.
D. None of the above.
Answer : C
236) Which of the following is true about servlets?
A. Servlets execute within the address space of web server
B. Servlets are platform-independent because they are written in java
C. Servlets can use the full functionality of the Java class libraries
D. Servlets can use the full functionality of the Java class libraries
Answer : D
237) Which of the following code is used to get an attribute in a HTTP Session object in servlets?
A. session.getAttribute(String name)
B. session.alterAttribute(String name)
C. session.updateAttribute(String name)
D. session.setAttribute(String name)
Answer : A
238) What are the functions of Servlet container?
A. Lifecycle management
B. Communication support
C. Multithreading support
D. All of the above
Answer : D
239) Which object of HttpSession can be used to view and manipulate information about a session?
A. session identifier
B. creation time
C. last accessed time
D. All mentioned above
Answer : D
240) Which of the following statements are correct about the status of the Http response.
A. A status of 200 to 299 signifies that the request was successful
B. A status of 300 to 399 are informational messages
C. A status of 400 to 499 indicates an error in the server
D. A status of 500 to 599 indicates an error in the client
Answer : C
241) Which methods are used to bind the objects on HttpSession instance and get the objects?
A. setAttribute
B. getAttribute
C. Both A & B
D. None of the above
Answer : C
242) To send text output in a response, the following method of HttpServletResponse may be used to get the appropriate Writer/Stream object.
A. getStream
B. getOutputStream
C. getBinaryStream
D. getWriter
Answer : C
243) Which method take a string not a URL?
A. sendRedirect
B. forward
C. Both
D. None
Answer : A
244) RequestDispatcher object is used
A. to include other resources
B. to include an image
C. to include xml object
D. to include e-mailing response
Answer : A
245) Which of the following are interface?
- 1. ServletContext
- 2. Servlet
- 3. GenericServlet
- 4. HttpServlet
A. 1,2,3,4
B. 1,2
C. 1,3,4
D. 1,4
Answer : B
246) What is the meaning of response.setHeader(“xyz”, “abc”);
A. Add a new header and value
B. Add an additional value to exiting header
C. Add a new header and value or add an additional value to exiting header
D. Add new header and value always
Answer : A
247) The life cycle of a servlet is managed by
A. servlet context
B. servlet container
C. the supporting protocol (such as http or https)
D. All of the above
Answer : B
248) Which of the following method sets application/context init parameter?
A. setParameter(String name,String value)
B. Its not possible in the method
C. setParameter(String name,Object value)
D. setParameter(Object name,Object value)
Answer : C
249) Which method shows the client what server is receiving?
A. goGet
B. doOption
C. doTrace
D. doPost
Answer : A
250) Which class provides stream to read binary data such as image etc. from the request object?
A. ServltInputStream
B. ServletOutputStream
C. Both A & B
D. None of the above
Answer : A
251) Which of these ways used to communicate from an applet to servlet?
A. RMI Communication
B. HTTP Communication
C. Socket Communication
D. All mentioned above
Answer : D
252) Which type of ServletEngine is a server that includes built-in support for servlets?
A. Add-on ServletEngine
B. Embedded ServletEngine
C. Standalone ServletEngine
D. None of the above
Answer : C
253) What type of servlets use these methods doGet(), doPost(),doHead, doDelete(), doTrace()?
A. Genereic Servlets
B. HttpServlets
C. All of the above
D. None of the above
Answer : B
254) Which cookie it is valid for single session only and it is removed each time when the user closes the browser?
A. Persistent cookie
B. Non-persistent cookie
C. All the above
D. None of the above
Answer : B
255) Sessions is a part of the SessionTracking and it is for maintaining the client state at server side.
A. True
B. False
Answer : A
256) Web server is used for loading the init() method of servlet.
A. True
B. False
Answer : A
257) Servlets handle multiple simultaneous requests by using threads.
A. True
B. False
Answer : A
258) Which method is used to send the same request and response objects to another servlet in RequestDispacher ?
A. forward()
B. sendRedirect()
C. Both A & B
D. None of the above
Answer : A
259) Which packages represent interfaces and classes for servlet API?
A. javax.servlet
B. javax.servlet.http
C. Both A & B
D. None of the above
Answer : A
260)Which class can handle any types of request so that it is protocol independent
A. GenericServlet
B. HttpServlet
C. Both A & B
D. None of the above
Answer : A
261) Which object is created by the web container at time of deploying the project?
A. ServletConfig
B. ServletContext
C. Both A & B
D. None of the above
Answer : B
262) What is the lifecycle of a servlet?
A. Servlet class is loaded
B. Servlet instance is created
C. init,Service,destroy method is invoked
D. All mentioned above
Answer : D
263) Which method in session tracking is used in a bit of information that is sent by a web server to a browser and which can later be read back from that browser?
A. HttpSession
B. URL rewriting
C. Cookies
D. Hidden form fields
Answer : C
264) Which one of the following scopes does the attribute in servlet is an object that can be set, get or removed?
A. session scope
B. request scope
C. application scope
D. All mentioned above
Answer : D
265) Which are the examples of Application Server?
A. Apache
B. Tomcat
C. JBoss
D. Weblogic
E. Both C & D
Answer : E
266) How many techniques are used in Session Tracking?
A. 4
B. 3
C. 2
D. 5
Answer : A
267) Which are the methods of generated Servlet?
A. jspInit()
B. _jspService()
C. jspDestroy()
D. All of the above
Answer : D
268) Servlet technology is used to create web application
A. True
B. False
Answer : A
269) How constructor can be used for a servlet?
A. Initialization
B. Constructor function
C. Initialization and Constructor function
D. Setup() method
Answer : C
270) What is the difference between servlets and applets?
- Servlets execute on Server; Applets execute on browser
- Servlets have no GUI; Applet has GUI
- Servlets creates static web pages; Applets creates dynamic web pages
- Servlets can handle only a single request; Applet can handle multiple requests
A. i, ii, iii are correct
B. i, ii are correct
C. i, iii are correct
D. I, ii, iii, iv are correct
Answer : B
271) Which of the following code retrieves the body of the request as binary data?
A. DataInputStream data = new InputStream()
B. DataInputStream data = response.getInputStream()
C. DataInputStream data = request.getInputStream()
D. DataInputStream data = request.fetchInputStream()
Answer : C
272) When destroy() method of a filter is called?
A. The destroy() method is called only once at the end of the life cycle of a filter
B. The destroy() method is called after the filter has executed doFilter method
C. The destroy() method is called only once at the begining of the life cycle of a filter
D. The destroyer() method is called after the filter has executed
Answer : A
273) How is the dynamic interception of requests and responses to transform the information done?
A. servlet container
B. servlet config
C. servlet context
D. servlet filter
Answer : D
274) Which are the session tracking techniques?
- i. URL rewriting,
- ii. Using session object,
- iii. Using response object,
- iv. Using hidden fields,
- v. Using cookies,
- vi. Using servlet object
A. i, ii, iii, vi
B. i, ii, iv, v
C. i, vi, iii, v
D. i, ii, iii, v
Answer : B
275) Which of the following code can be used to set the content type for the body of the response?
A. request.setContentType(type)
B. response.setContentType(type)
C. header.setContentType(type)
D. None of the above.
Answer : B
276) Which of the following code sends a cookie in servlet?
A. response.addCookie(cookie);
B. response.sendCookie(cookie);
C. response.createCookie(cookie);
D. None of the above
Answer : A
277) A servlet maintain session in
A. Servlet container
B. Servlet context
C. Servlet request heap
D. Servlet response heap
Answer : B
278) In the web.xml, session configuration is <session-config><session timeout>0<session-timeout></session-config> What does this means?
A. Session are never invalidated.
B. Sessions are never created.
C. Session timeout is 0 so sessions never get created.
D. None of the above
Answer : B
279) Which of the following code retrieves the value of a request parameter?
A. Header.getParameter(name)
B. response.getParameter(name)
C. request.getParameter(name)
D. None of the above.
Answer : C
280) The tasks – authentication-blocking of requests, data compression, logging and auditing – are performed by
A. servlet filter
B. servlet config
C. servlet context
D. servlet container
Answer : A
281) Which of the following code can be used to add a header with the given name and integer value?
A. request.addHeader(name,value)
B. response.addIntHeader(name,value)
C. Header.addDateHeader(name,value)
D. None of the above
Answer : B