Servlets/Servlets - Java (MCQ) questions Sample Test,Sample questions

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

1.getStreamB. . .

2.getOutputStream

3.getBinaryStream

4.getWriter


Question:
 How many JDBC driver types does Sun define?
One

1.Two.

2.Two

3.Four

4.Three


Question:
 In the following statements identify the disadvantages of CGI?

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

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

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

4.All mentioned above


Question:
 RequestDispatcher object is used

1.to include other resources

2.to include an image

3.to include xml objec

4. to include e-mailing response


Question:
 The life cycle of a servlet is managed by

1.servlet context

2.servlet container

3.the supporting protocol (such as http or https)

4.All of the above


Question:
 What is the meaning of response.setHeader("xyz", "abc

1.Add a new header and value

2.Add an additional value to exiting header

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

4.Add new header and value always


Question:
 Which method is used to send the same request and response objects to another servlet in RequestDispacher ?

1.forward()

2. sendRedirect()

3.Both A & B

4.None of the above


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

1.setPageType()

2.. setContentType()

3.. setContentType()

4. setResponseType()


Question:
 Which object is created by the web container at time of deploying the project?

1. ServletConfig

2.ServletContext

3.Both A & B

4.None of the above


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

1.new MimeType()

2.request.getContentType()

3. response.getContentType()

4.None of the above


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

1.setParameter(String name,String value

2.Its not possible in the method

3.setParameter(String name,Object value)

4.setParameter(Object name,Object value)


Question:
 Which type of ServletEngine is a server that includes built-in support for servlets?

1.Add-on ServletEngine

2.Embedded ServletEngine

3.Standalone ServletEngine

4.None of the above


Question:
. What is bytecode?

1.Machine-specific code

2.Java code

3.Machine-independent code

4.None of the mentioned


Question:
How many techniques are used in Session Tracking?

1.4

2.3

3.2

4.5


Question:
In HTTP Request what asks for the loopback of the request message, for testing or for troubleshooting?

1.PUT

2.OPTIONS

3.DELETE

4.TRACE


Question:
In HTTP Request what asks for the loopback of the request message, for testing or for troubleshooting?

1.PUT

2.OPTIONS

3.DELETE

4.TRACE


Question:
In HTTP Request what asks for the loopback of the request message, for testing or for troubleshooting?

1.PUT

2.OPTIONS

3.DELETE

4.TRACE


Question:
In HTTP Request what asks for the loopback of the request message, for testing or for troubleshooting?

1.PUT

2.OPTIONS

3.DELETE

4.TRACE


Question:
What are the features added in Servlet 2.5?

1.Dependency on J2SE 5.0

2.Support for annotations

3.Loading the class

4.All of these


Question:
What are the functions of Servlet container?

1. Lifecycle management

2.Communication support

3.Multithreading support

4.All of the above


Question:
What are the functions of Servlet container?

1. Lifecycle management

2.Communication support

3.Multithreading support

4.All of the above


Question:
What is the lifecycle of a servlet?

1.Servlet class is loaded

2.Servlet instance is created

3.init,Service,destroy method is invoked

4.All mentioned above


Question:
What type of servlets use these methods doGet(), doPost(),doHead, doDelete(), doTrace()?

1.GenereiAll of the above

2.HttpServlets

3.All of the above

4.None of the above


Question:
Which are the examples of Application Server?

1. JBoss

2.Weblogic

3. Tomcat c.

4. Both A & B


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

1.GenericServlet

2.HttpServlet

3.Both A & B

4.None of the above


Question:
Which class provides stream to read binary data such as image etc. from the request object?

1.ServltInputStream

2.ServletOutputStream

3.Both A & B

4.None of the above


Question:
Which class provides stream to read binary data such as image etc. from the request object?

1.ServltInputStream

2.ServletOutputStream

3.Both A & B

4.None of the above


Question:
Which cookie it is valid for single session only and it is removed each time when the user closes the browser?

1. Persistent cookie

2.Non-persistent cookie

3.All the above

4.None of the above


Question:
Which HTTP Request method is non-idempotent?

1.GET

2.POST

3.BOTH A & B

4.None of the above


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

1.Both Type 1 and Type 2

2.Both Type 1 and Type 3

3. Both Type 3 and Type 4

4.Type 4 only


Question:
Which method in session tracking is used in a bit of information that is sent by a web server to a browser and which can later be read back from that browser?

1.HttpSession

2.URL rewriting

3.Cookies

4.Hidden form fields


Question:
Which method shows the client what server is receiving?

1.goGet

2. doOption

3. doTrace

4. doPost


Question:
Which method take a string not a URL?

1.sendRedirect

2.forward

3.Both

4.None


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

1.setAttribute

2.getAttribute

3.Both A & B

4. None of the above


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

1.session identifier

2.creation time

3. last accessed time

4.All mentioned above


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

1.1,2,3,4

2. 1,2

3. 1,3,4

4.1,4


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

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

2.A status of 300 to 399 are informational messages

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

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


Question:
Which of these ways used to communicate from an applet to servlet?

1.RMI Communication

2.HTTP Communication

3.Socket Communication

4.All mentioned above


Question:
Which one of the following scopes does the attribute in servlet is an object that can be set, get or removed?

1.session scope

2.request scope

3.application scope

4. All mentioned above


Question:
Which packages represent interfaces and classes for servlet API?

1.javax.servlet

2. javax.servlet.http

3.Both A & B

4.None of the above


Question:
Which packages represent interfaces and classes for servlet API?

1.javax.servlet

2. javax.servlet.http

3.Both A & B

4.None of the above


More MCQS

  1. Servlets - Java (MCQ) questions
Search
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!