Advanced Java Programming (3160707) MCQs

MCQs of Servlet API and Overview

Showing 41 to 50 out of 57 Questions
41.
What is default session time of HttpSession?
(a) 30 seconds
(b) 30 milliseconds
(c) 30 minutes
(d) there is no default session time
Answer:

Option (c)

42.
Which code from the following will only retrieve the session?
(a) HttpSession hs=request.getSession()
(b) HttpSession hs=request.getSession(false)
(c) HttpSession hs=request.getSession(true)
(d) All of these
Answer:

Option (d)

43.
Differentiate ServletConfig and ServletContext object.
(a) Both are same
(b) Scope of ServletConfig is servlet and Scope of ServletContext is web application
(c) Scope of ServletConfig is web application and Scope of ServletContext is servlet
(d) ServletContext object can’t be nullified but ServletConfig object can be.
Answer:

Option (b)

44.

Which method is used to send the same request and response objects to another servlet ?

(a)

forward()

(b)

next()

(c)

sendForward()

(d)

sendRedirect()

Answer:

Option (a)

45.

Which class can handle any type of request so that it is protocol-independent?

(a)

HttpServlet

(b)

Request

(c)

Http

(d)

GenericServlet

Answer:

Option (d)

46.

In the following statements identify the disadvantages of CGI?

(a)

If number of clients increases, it takes more time for sending response.

(b)

For each request, it starts a process and Web server is limited to start processes.

(c)

It uses platform dependent language e.g. C, C++, perl.

(d)

All mentioned

Answer:

Option (d)

47.

Which class provide implementation for service() method ?

(a)

GenericServlet

(b)

HttpServlet

(c)

Servlet

(d)

none of the above

Answer:

Option (a)

48.

Deployment Descriptor(DD) is a _________ .

(a)

Servlet used to maintain other servlet.

(b)

Text document

(c)

XML document that is used by Web Container to run servlets and JSPs.

(d)

Library file.

Answer:

Option (c)

49.

Consider below web.xml file,

<web-app>
  <servlet>
    <servlet-name>DemoServlet </servlet-name>
    <servlet-class>DemoServlet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>DemoServlet </servlet-name>
    <url-pattern>/Demo</url-pattern>
  </servlet-mapping>
</web-app>  

Which url Is use to access DemoServlet ?

(a)

/Demo

(b)

/*

(c)

/DemoServlet

(d)

/Servlet

Answer:

Option (a)

50.

Consider below web.xml file,

<web-app>
   <filter>
        <filter-name>Filter1</filter-name>
        <filter-class>Filter1</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>Filter1</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
</web-app>

Filter1 is apply to ________ Servlet.

(a)

Filter1

(b)

All Filter

(c)

Single Servlet

(d)

All Servlet

Answer:

Option (d)

Showing 41 to 50 out of 57 Questions