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
Given 
Cookie cookie = new Cookie("user", user);  
cookie.setMaxAge(0);
Which of the following is true?
  1. This cookie will  never expire
  2. This cookie will expire immediately
  3. This cookie will be expire when the browser exists
  4. This will cause IllegalArgumentException being thrown at runtime
Show Answer
Share Facebook gmail Twitter
2
Which of the following can be used to do onetime applicationwide initialization after the application is deployed?
  1. init() of HttpServlet
  2. contextInitialized() of ServletContextListener 
  3. requestInitialized() of ServletRequestListener 
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
5
Which RequestDispatcher method is best suited when a servlet needs to merge output from two other servlets?
  1. request(ServletRequest req, ServletResponse res)
  2. include(ServletRequest req, ServletResponse res)
  3. dispatch(ServletRequest req, ServletResponse res)
  4. forward(ServletRequest req, ServletResponse res)
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
8
Which of following will avoid HTTP 404 status when only application context path is entered in the URL?
  1. using <welcome-file> in web.xml
  2.  <url-pattern> in web.xml
  3. by providing index.html file in the web application
  4. by providing index.html file in the web application
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
17
An object needs to be notified when it is added to the session. How can this be acheived?
  1. It must implement HttpSessionActivationListener
  2. It must implement HttpSessionBindingListener
  3. It must implement HttpSessionListener
  4. This cannot be achieved
Show Answer
Share Facebook gmail Twitter
18
Which  listener method will be called when invalidate() method on the session is called?
  1.  sessionDestroyed() of HttpSessionListener
  2. valueUnbound() of HttpSessionListener
  3.  sessionDestroyed() of HttpSessionBindingListener
  4. valueUnbound() of HttpSessionBindingListener
Show Answer
Share Facebook gmail Twitter
19
Which method of HttpServletResponse is used to redirect an HTTP request to another URL?
  1. redirectURL()
  2. redirectHttp()
  3. sendRedirect()
  4. getRequestDispatcher()
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Read more papers :