Select chapter



basics (7.papers)
constructors (1.papers)
packages (1.papers)
inheritance (7.papers)
misc (3.papers)
exceptions (5.papers)
threads (4.papers)
overloading (1.papers)
jsp (3.papers)
servlets (9.papers)
jdbc (2.papers)
util (1.papers)
xml (2.papers)
IO stream (3.papers)
Hide

Sponsored Links


  

java interview questions and answers

1
A session whose timeout period has been set to -1 indicates that
  1. session will never expire.
  2. session  will expire when user closes all browser windows.
  3. session  will expire immediately.
  4. This is invlaid value that will lead to IllegalArgumentException at runtime.
Show Answer
Share Facebook gmail Twitter
2
Which of the following are definitely thread-safe in a servlet?
  1. Local variables
  2. Instance variables
  3. Static variables
  4. Context attributes
Show Answer
Share Facebook gmail Twitter
3
Where should the servlet class be placed in a web application?
  1. /WEB-INF
  2. /WEB-INF/classes
  3. /classes
  4. /WEB-INF/lib
Show Answer
Share Facebook gmail Twitter
4
Which method of HttpServletRequest can be used to get cookies?
  1. String getCookie(String name)   
  2. Cookie getCookie(String name)   
  3. Cookie[] getCookies()   
  4. String[] getCookies()  
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
8
A class extending GenericServlet must override the method
  1. public void init() throws ServletException 
  2. public void service(ServletRequest req, ServletResponse res) throws ServletException, java.io.IOException 
  3. public void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, java.io.IOException 
  4. public void init(ServletConfig config) throws ServletException 
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
11
Which method is used to save object in request scope? 
  1. addAttribute(String name, String obj)
  2. putAttribute(String name, Object obj)
  3. saveAttribute(String name, String obj)
  4. setAttribute(String name, Object obj)
Show Answer
Share Facebook gmail Twitter
12
Servlet initialization parameter can be obtained using
  1. getParameter(String name) of ServletConfig
  2. getInitParameter(String name) of ServletContext 
  3. getInitParameter(String name) of ServletConfig
  4. getParameter(String name) of ServletContext
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
14
getSession() method of HttpSession is equivalent to
  1. getSession(true)
  2. getSession(false)
Show Answer
Share Facebook gmail Twitter
15
Which of the folowing is true for HTTP POST method?
  1. POST allows users to bookmark URLs with parameters.
  2. The POST method should not be used when large amount of data needs to be transferred.
  3. POST allows secure data transmission over the http method.
  4. POST method sends data in the body of the request.
Show Answer
Share Facebook gmail Twitter
16
In a web application where is the jar file placed?
  1. example/WEB-INF
  2. example/lib
  3. example/WEB-INF/lib
  4. example/WEB-INF/classes
Show Answer
Share Facebook gmail Twitter
17
encodeURL() and encodeRedirectURL() are methods in
  1. HttpSession
  2. HttpServletResponse
  3. HttpServletRequest
  4. HttpServlet
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Read more papers :