Servlets FAQ's!!!

1.when the init() method is overridden what should be the first line in the coding?

a. init(ServletConfig sc);
b. super.init(sc);
c. res.setContentType(“text/html”);
d. Can be Any Statement.

2. When the object is added to the servletContext , it can be destroyed

a. at the end of the session
b. at the end of the page
c. at the end of the request
d. cannot be destroyed unless the application is shutdown.


3. what is singleThreadModel servlet?


4.Explain the life cycle of a servlet

5.What the line res.setContentType(“text/html”) signify?
a)MIME type b)response type c)data type d)document type

6.The response .encodeURL() method is used to
a)create cookie
b)append URL with Cookie
c)convert non standard characters into standard characters
d)create a session

7.The component used to forward a user to another page is
a)response.sendRedirect
b)RequestForwarder
c)RequestDispatcher
d)Requester

8)For each Client’s reqest a separate instance of a servlet is loaded(True/False)

9)if a servlet code is not thread-safe,then we have to implement this interface toavoid multi-thread access
a)synchronized
b)Serialized
c)SingleThreadModel
d)ThreadSafeInterface

10)How many number of ServletContext objects per Application
a) many B) 0 c) 1 d) depends on the number of user

11)Initializatoin parameter can be accessed in this method

a)service() b) init() c) destroy() d) all the methods

12)All Servlets will participate in session by default(True/False)

13)A servlet class must be place user the following directory inside our j2ee application

a)any directory
b)under WEB-INF
c)under WEB-INF/classes
d)any classes directory

14)The following objects are passed explicitly during forwarding and including of one servlet in another servlet

a)servlet b)session c)response d)servletContext

15) All the objects that are stored in the HttpSession object, must also be implementing java.io.Serializable. say True/False.