0% found this document useful (0 votes)
23 views6 pages

Servlet MCQ

Uploaded by

rms744746
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views6 pages

Servlet MCQ

Uploaded by

rms744746
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

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

a. GenericServlet b. HttpServlet c. Both A & B d. None of the above

Which object is created by the web container at time of deploying the project?
a. ServletConfig b. ServletContext c. Both A & B d. None of the above

How many techniques are used in Session Tracking?


a. 4 b. 3 c. 2 d. 5

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 above

What is the lifecycle of a servlet?


a. Servlet class is loaded
b. Servlet instance is created
c. init,Service,destroy method is invoked
d. All mentioned above

. Which HTTP Request method is non-idempotent?


a. GET
b. POST
c. BOTH A & B
d. None of the above

Which of the following code is used to get an attribute in a HTTP Session object in servlets?
 A. session.getAttribute(String name)

 B. session.alterAttribute(String name)

 C. session.updateAttribute(String name)

 D. session.setAttribute(String name)

Which method is used to specify before any lines that uses the PintWriter?

 A. setPageType()

 B. setContextType()

 C. setContentType()

 D. setResponseType()

What are the functions of Servlet container?

 A. Lifecycle management

 B. Communication support

 C. Multithreading support

 D. All of the above

What is bytecode?

 A. Machine-specific code

 B. Java code

 C. Machine-independent code

 D. None of the mentioned

Which object of HttpSession can be used to view and manipulate information about a session?

 A. session identifier

 B. creation time

 C. last accessed time

 D. All mentioned above

Which of the following is true about servlets?

 A. Servlets execute within the address space of web server

 B. Servlets are platform-independent because they are written in java


 C. Servlets can use the full functionality of the Java class libraries

 D. Servlets execute within the address space of web server, platform independent and uses the
functionality of java class libraries

Which of the following statements are correct about the status of the Http response.

 A. A status of 200 to 299 signifies that the request was successful

 B. A status of 300 to 399 are informational messages

 C. A status of 400 to 499 indicates an error in the server

 D. A status of 500 to 599 indicates an error in the client

Which JDBC driver Type(s) can be used in either applet or servlet code?

 A. Both Type 1 and Type 2

 B. Both Type 1 and Type 3

 C. Both Type 3 and Type 4

 D. Type 4 only

Which of the following code retrieves the MIME type of the body of the request?

 A. new MimeType()

 B. request.getContentType()

 C. response.getContentType()

 D. None of the above

Which methods are used to bind the objects on HttpSession instance and get the objects?

 A. setAttribute

 B. getAttribute

 C. Both A & B

 D. None of the above

To send text output in a response, the following method of HttpServletResponse may be used to
get the appropriate Writer/Stream object.

 A. getStream
 B. getOutputStream

 C. getBinaryStream

 D. getWriter

Which method take a string not a URL?

 A. sendRedirect

 B. forward

 C. Both

 D. None

RequestDispatcher object is used

 A. to include other resources

 B. to include an image

 C. to include xml object

 D. to include e-mailing response

Which of the following are interface? 1. ServletContext 2. Servlet 3. GenericServlet 4.


HttpServlet

 A. 1,2,3,4

 B. 1,2

 C. 1,3,4

 D. 1,4

What is the meaning of response.setHeader("xyz", "abc");

 A. Add a new header and value

 B. Add an additional value to exiting header

 C. Add a new header and value or add an additional value to exiting header

 D. Add new header and value always

The life cycle of a servlet is managed by

 A. servlet context
 B. servlet container

 C. the supporting protocol (such as http or https)

 D. All of the17 above

Which of the following method sets application/context init parameter?

 A. setParameter(String name,String value)

 B. Its not possible in the method

 C. setParameter(String name,Object value)

 D. setParameter(Object name,Object value)

Which method shows the client what server is receiving?

 A. goGet

 B. doOption

 C. doTrace

 D. doPost

What is the difference between servlets and applets?


i. Servlets execute on Server; Applets execute on browser
ii. Servlets have no GUI; Applet has GUI
iii. Servlets creates static web pages; Applets creates dynamic web pages
iv. Servlets can handle only a single request; Applet can handle multiple requests
a) i, ii, iii are correct
b) i, ii are correct
c) i, iii are correct
d) i, ii, iii, iv are correct

How constructor can be used for a servlet?

Setup() method
Constructor function
Initialization and Constructor function
Initialization

You might also like