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 : B

Explaination

Each time the server receives a request for a servlet, the server spawns a new thread and calls service() method.

Q 2 - Which of the following method can be used to get the value of form parameter?

A - request.getParameter()

B - request.getParameterValues()

C - request.getParameterNames()

D - None of the above.

Answer : A

Explaination

You call request.getParameter() method to get the value of a form parameter.

Q 3 - Which of the following code retrieves the name of the authentication scheme?

A - new AuthType()

B - response.getAuthType()

C - request.getAuthType()

D - None of the above.

Answer : C

Explaination

request.getAuthType() returns the name of the authentication scheme used to protect the servlet, for example, BASIC or SSL or null if the JSP was not protected.

Q 4 - Which of the following code retrieves the value of a request parameter?

A - Header.getParameter(name)

B - response.getParameter(name)

C - request.getParameter(name)

D - None of the above.

Answer : C

Explaination

request.getParameter(name) returns the value of a request parameter as a String, or null if the parameter does not exist.

Q 5 - Which of the following code encodes the specified URL for use in the sendRedirect method?

A - response.encodeRedirectURL(url)

B - request.encodeRedirectURL(url)

C - Header.encodeRedirectURL(url)

D - None of the above.

Answer : A

Explaination

response.encodeRedirectURL(url) encodes the specified URL for use in the sendRedirect method or, if encoding is not needed, returns the URL unchanged.

Answer : B

Explaination

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

Answer : D

Explaination

All of the above filters are suggested by the servlet specifications.

Q 9 - Which of the following way can be used to keep track of previous client request?

A - Using cookies.

B - Using hidden form fields.

C - Using URL rewriting.

D - All of the above.

Answer : D

Explaination

All of the above can be used to keep track of previous client request.

Q 10 - Which of the following code is used to get three-letter abbreviation for this locale's language in servlets?

A - response.getISO3Language()

B - Locale.getISO3Language()

C - request.getISO3Language()

D - None of the above.

Answer : C

Explaination

request.getISO3Language() returns a three-letter abbreviation for this locale's language.


servlets-questions-answers.htm

Advertisements