Servlet Interview questions for freshers part-II
16.Name the class that can be used to get the cookies from the client browser
a) HttpServletResponse
Ans:b) HttpServletRequest
c) SessionContext
d) SessionConfig
17.Which of the following is not a server-side technology?
a) Servlets
b) Java Server Pages
Ans:c) DHTML
d) CGI
18.Which method returns an array of String objects containing all of the values the given request parameter has
a) getParameter()
b) getParameterNames()
Ans:c) getParameterValues()
19.Name the class that includes the getSession method that is used to get the HttpSession object.
Ans:a) HttpServletResponse
b) HttpServletRequest
c) SessionContext
d) SessionConfig
20.The method getWriter returns an object of type PrintWriter. This class has println methods to generate output. Which of these classes define the getWriter method? Choose the correct option
a) HttpServletRequest
Ans:b) HttpServletResponse
c) ServletConfig
d) ServletContext
21.To send text output in a response, the following method of HttpServletResponse may be used to get the appropriate Writer/Stream object. Choose the correct option.
a) getStream
b) getOutputStream
c) getBinaryStream
Ans:d) getWriter
22. Which method returns names of the request parameters as Enumeration of String objects
a) getParameter
Ans:b) getParameterNames
c) getParameterValues
23.Servlets classes specific to your application are placed in which directory on the TOMCAT Server?
a)
Ans:b)
c)
d)
24.In java, three tier architecture is usually( in most generic way) implemented using
a) Front end in HTML, middle tier in pure java, odbc in backend
b) Front end in applets, middle tier in beans, odbc in backend
Ans:c) Front end on HTML/Swing, middle tier in Servlets/Beans/EJB and Database server in the back end.
25.Why are programs needed on Server-side?
a) Dynamic Content generation
b) Database access
c) Transactions
Ans:d) All of the above
26.Any Java class can be a servlet provided
i] It implements the javax.servlet.Servlet Interface.
ii] Extends from any class that implements the same.
a) Only i is true, ii cannot be used
b) Only ii is true, i cannot be used
Ans:c) Either of i or ii can be used
d) Both i and ii cannot be used
27.Servlet becomes thread safe by implementing the javax.servlet .SingleThreadModel interface
Ans:a) as every request is handled by separate instances of the servlet
b) as a single thread serves all the client requests
c) as all the requests are serialised
d) a first to-be loaded servlet and is loaded by the server during startup
28.You must ideally use Servlets for
i] Extending Server functionality and simple business logic
ii] Work flow management and presentation logic
iii] Work flow management and complex database queries
iv] NON-HTML data generation such as XML generation and parser
a) i only
b) i, ii, iii
Ans:c) i and ii only
d) All of i, ii, iii and iv
29.Some purposes for which servlets can be used are:
i] file access on the client side
ii] starting distributed transactions
iii] any purpose at the server end
iv] calling an enterprise bean
a) All of i, ii, iii and iv
Ans:b) ii, iii and iv only. File access is not possible.
c) iii only
d) None of i, ii, iii and iv
30.Looking at the following piece of the code, Select the correct statement out of the given options
Class.forName(”sun.jdbc.odbc.JdbcOdbcDriver”);
a) This is exactly same as import statement
b) This is used to make a connection with database
Ans:c) Usually written in the init() method of Servlet to load the driver into memory
31.Servlets can follow
a) single thread model
b) multi thread model
Ans:c) both
32.Which of the following server can host servlets?
a)Apache server
b)IIs
c)Windows 2000 Server
Ans:d)Tomcat Server
33.The URL in the POST method can be used to find out the query parameters
a) true
Ans:b) false




Leave a Reply
You must be logged in to post a comment.