Servlets - Online Quiz


Advertisements


Following quiz provides Multiple Choice Questions (MCQs) related to Servlets Framework. You will have to read all the given answers and click over the correct answer. If you are not sure about the answer then you can check the answer using Show Answer button. You can use Next Quiz button to check new set of questions in the quiz.

Questions and Answers

Answer : C

Explaination

Java Servlets are programs that run on a Web or Application server and act as a middle layer between a request coming from a Web browser or other HTTP client and databases or applications on the HTTP server.

Q 2 - What is javax.servlet.http.HttpServlet?

A - interface

B - abstract class

C - concreate class

D - None of the above.

Answer : B

Explaination

javax.servlet.http.HttpServlet is an abstract class.

Q 3 - Which of the following code is used to get names of the attributes in servlet?

A - response.getAttributeNames()

B - request.getAttributeNames()

C - Header.getAttributeNames()

D - None of the above.

Answer : B

Explaination

request.getAttributeNames() returns an enumeration containing the names of the attributes available to this request.

Q 4 - Which of the following code retrieves the query string that is contained in the request URL after the path?

A - Header.getQueryString()

B - response.getQueryString()

C - request.getQueryString()

D - None of the above.

Answer : C

Explaination

request.getQueryString() returns the query string that is contained in the request URL after the path.

Q 5 - Which of the following code indicates whether the response has been committed?

A - response.isCommitted()

B - request.isCommitted()

C - Header.isCommitted()

D - None of the above.

Answer : A

Explaination

response.isCommitted() returns a boolean indicating if the response has been committed.

Answer : A

Explaination

response.addDateHeader(name,date) adds a response header with the given name and date-value.

Answer : A

Explaination

The init method is designed to be called only once. It is called by the web container to indicate to a filter that it is being placed into service.

Answer : A

Explaination

Create cookie using new operator on Cookie class.

Q 9 - Does server automatically keep any record of previous client request?

A - true

B - false

Answer : B

Explaination

HTTP is a stateless protocol which means each time a client retrieves a Web page, the client opens a separate connection to the Web server and the server automatically does not keep any record of previous client request.

Answer : A

Explaination

You can call public void setMaxInactiveInterval(int interval) method of session to set the timeout for a session individually.


servlets-questions-answers.htm

Advertisements
E-Books Store