Showing posts with label practice exam. Show all posts
Showing posts with label practice exam. Show all posts

Friday, April 29, 2011

SCWCD Mock Exam 2 - Answers

Below are the Answers to the Questions that were part of the Practice Exam in the previous chapter. If the answer you chose matches the answer given here, great. In case it doesn't, don't worry. Just revisit the chapter that covers the topic and revise the chapter. You will be able to crack the exams easily!!!

Answers:

Question1:
E.
Question2:
A.
Question3:
ServletContextListener
Question4:
C.
Question5:
A, C.
Question6:
D.
Question7:
B.
Question8:
C.
Question9:
B.
Question10:
A and D.
Question11:
A and B.
Question12:
A and D.
Question13:
B and C.
Question14:
D.
Question15:
A.
Question16:
D.
Question17:
D.
Question18:
D.
Question19:
A and D.
Question20:
B.
Question21:
A and B.
Question22:
C.
Question23:
B.
Question24:
C.
Question25:
A.
Question26:
D.
Question27:
A and D.
Question28:
B and D.
Question29:
D.
Question30:
C and D.
Question31:
A.
Question32:
A, C, and D.
Question33:
D.
Question34:
C.
Question35:
C.
Question36:
A and D.
Question37:
B, C, and D.
Question38:
D.
Question39:
A.
Question40:
B and C.
Question41:
A.
Question42:
B.
Question43:
A.
Question44:
B.
Question45:
A.
Question46:
A.
Question47:
B.
Question48:
A.
Question49:
C and D.
Question50:
D.
Question51:
C.
Question52:
C and D.
Question53:
B.
Question54:
A.
Question55:
C.
Question56:
SingleThreadModel
Question57:
C.
Question58:
B and C.
Question59:
B.
Question60:
D.

Previous Chapter: Mock Exam 2

This is the Last Chapter in the SCWCD Certification Exam Series. So, there is no Next Chapter. However, you can access the Index of all chapters on the SCWCD Exam Series by Clicking Here

SCWCD Mock Exam 2

This chapter is the Second and last of our 2 practice Exams. It contains 60 Questions and you can take upto 90 minutes to answer all of them.

Remember that the exam contains the same number of Questions ‘60’ and you will be given the same 90 minutes only. So, make sure you time yourself and don't use more than the allotted time.

Questions

Question 1:

Which of the following can call the init method?
A. doPut
B. session
C. service
D. request
E. the container

Question 2:

Which corresponding method in the HttpServlet class do you use to retrieve the value of a text field on an HTML form?
A. doPost
B. getParameter(String fieldName)
C. doGet(String fieldName)
D. getHTTP(String fieldName)

Question 3:

Please provide the interface name which you implement to create a context listener.
______________________________

Question 4:

Which method is used to get a ServletContext object?
A. getContextServlet
B. getServlet
C. getContext
D. getServletContext

Question 5:

Which two of the following are HttpServlet class methods (choose two)?
A. doPut
B. getRequest
C. doPost
D. post

Question 6:

Which method does the container call at the end of the servlet lifecycle?
A. doDelete
B. end
C. finalize
D. destroy

Question 7:

What type of HTTP request is normally used for simple HTML page requests?
A. POST
B. GET
C. DELETE
D. CALL

Question 8:

The getInitParameterNames method returns what?
A. Enumeration of string objects with session-wide parameters.
B. String array with session-wide parameters.
C. Enumeration of string objects with application-wide parameters.
D. String array with application-wide parameters.

Question 9:

What types of events trigger a POST type request?
A. When a user clicks a hyperlink.
B. When a user clicks a button on an HTML form whose method is set to POST, as in method=post.
C. This is determined by the browser based on the size of the request.
D. This is determined by the server based on the size of the request.

Question 10:

Read the following code:
protected void service(HttpServletRequest req,
HttpServletResponse resp)
throws ServletException, IOException
{ response.setContentType("text/plain");
PrintWriter out = response.getWriter();
StringBuffer html = new StringBuffer();
html.append("< html >\n");
html.append("< head >< title >Servlet Example" + "< /title >< /head >\n");
html.append("< body >\n");
html.append("Servlet Example");
html.append("< /body >");
html.append("< /html >");
out.print( html.toString() );
}

Which two statements are true regarding this code (choose two)?
A. When a user sends a request to the container (assume servlet has not been loaded), this is the first method it calls.
B. When a user sends a request to the container (assume servlet has not been loaded), this is the second method it calls.
C. The doGet method will be called next.
D. The doGet method will not be called next.

Question 11:

What causes a servlet to load?
A. A Web server start.
B. The container detects that a class file has changed.
C. It is configured to do so periodically.
D. It is loaded upon every request.

Question 12:

Which two of the following are benefits of the POST method (choose two)?
A. It can send unlimited length data as part of its HTTP request body.
B. It allows bookmarks.
C. It uses simple query strings.
D. It hides data because it isn't passed as a query string, but is passed instead in the message body.

Question 13:

Which of the following are application-wide actions?
A. Context.setAttribute("applicationName", "Certification by Que");

B. config.getServletContext .setAttribute("applicationName", "Certification by Que");

C. config.getServletContext .getAttribute("applicationName", "Certification by Que");

D. Context .setAttribute("applicationName", "Certification by Que");

Question 14:

What is the benefit of using the HEAD HTTP method?
A. It hides the requester identity.
B. It masks the IP address.
C. It can handle any size request.
D. It is the smallest type request.

Question 15:

Which interface defines the methods for retrieving form parameters?
A. ServletRequest
B. ServletResponse
C. HTTPRequest
D. HTTPResponse

Question 16:

When does the container call init?
A. With each request for a given servlet.
B. Only on the first request for each user.
C. It is not called by the container.
D. Only at the beginning of the servlet lifecycle.

Question 17:

Which method do you use to retrieve a single value if you know the particular parameter name?
A. getParameterName(String parameterName)
B. getParameterValues(String parameterName)
C. getParameters(String parameterName)
D. getParameter(String parameterName)

Question 18:

Which method returns the URL to the resource that is mapped to a specified path?
A. getRealPath(String path)
B. getPath(String path)
C. getPathReal(String path)
D. getResource(String path)

Question 19:

Read the following code:

protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
{
// Serve the requested resource,
// including the data content.
}

Which two statements are true regarding this code (choose two)?
A. The doGet() method is called when the container receives an HTTP GET request.
B. The container always services a request with a doGet request as the last method called.
C. The request object has session scope.
D. The HTTP GET method may include parameters that are retrievable from the request object.

Question 20:

How do you perform programmatic server-side includes?
A. setForward(String url)
B. RequestDispatcher
C. Request
D. getResource(String url)

Question 21:

Which of the following is true?
A. ServletContext.getRequestDispatcher()— This method uses absolute paths.
B. ServletRequest.getRequestDispatcher (String path)— The path may be relative, but cannot extend outside current servlet context.
C. ServletRequest.getNamedDispatcher(String path)— The path may be relative.
D. ServletContext.getRequestDispatcher()— This method uses relative paths.

Question 22:

Which of the following is correct?
A. Enumeration names = request.getNames() ;
B. String[] names = request.getNames() ;
C. Enumeration parameterNames = request.getParameterNames() ;
D. String[] parameterNames = request.getParameterNames() ;

Question 23:

Suppose the container received an HTTP POST request. How would you process this request in the servlet's doGet method?
A. This isn't possible. The doPost method will receive the request, not the doGet method.
B.
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
{
//often just throw it at doGet()
doGet(request, response);
}



C. If there is no form parameters the container will automatically send the request to the doGet method.
D.
protected void init(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
{
//often just throw it at doGet()
doGet(request, response);
}

Question 24:

Which method corresponds to the HTTP GET method?
A. get
B. httpGet
C. doGet
D. getHTTP

Question 25:

It happens often that pages move around and a URL becomes invalid. Throwing back a 404 error isn't nice. What could you do that is better?
A. Use the sendRedirect method to send viewers to a temporary page.
B. Use the sendTemporary method to send viewers to a temporary page.
C. Use the setTemporary method to specify a temporary page and set the context parameter to the new URL.
D. Use the redirect method to send viewers to a temporary page.

Question 26:

Which of the following method lists are in the correct lifecycle order?
A. request start doPost end
B. service start response destroy
C. request init getPost
D. init service destroy

Question 27:

Which two of the following are called only once during the lifetime of a servlet (choose two)?
A. destroy
B. doPut
C. service
D. init
E. config

Question 28:

Which two of the following HttpServlet class methods receives the response object (choose two)?
A. get
B. doPut
C. getHTTP
D. doGet

Question 29:

What happens if you redirect a request to another URL after some of the response has already been returned?
A. The container simply discards the partial response and jumps to the new URL.
B. The container gets confused.
C. The specification doesn't say what the container is supposed to do. It is up to the vendor to decide.
D. The container throws IllegalStateException.

Question 30:

Read the following code:
public void service(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("< html >");
out.println("< head >< title >Servlet Error Handling " +
"Example< /title >< /head >");
out.println("< body >");
out.println("A skimpy, but complete servlet.");
out.println("< /body >");
out.println("< /html >");
}
}

Which two statements are true regarding this code (choose two)?
A. The doGet, doPost, or doPut method is called next depending on the type of request.
B. This code is invalid because it doesn't call one of the doGet, doPost, or doPut methods.
C. This code is valid and will handle all three types of HTTP requests including GET, POST, and PUT.
D. The next method invoked is destroy.

Question 31:

How do you set, get, and change application-level (not session-level) attributes and talk to the servlet container?
A. ServletContext
B. Context
C. Response
D. Request

Question 32:

Which three options are events that would trigger a GET type request (choose three)?
A. A form submission with the METHOD='GET'.
B. Uploading a file.
C. A user clicking a hyperlink.
D. Typing in the address text box on a browser.
E. Sending email.

Question 33:

How do you get application-level initialization parameters?
A. You use the getParameterValues method.
B. You use the getInitValues method.
C. You call the init method, which returns an array of initialization parameters.
D. You use the getInitParameter and getInitParameterNames methods.

Question 34:

You normally write a servlet by overriding the doPut, doGet, and doPost methods. Which class do they come from?
A. HttpServletRequest
B. HttpServletResponse
C. HttpServlet
D. HttpSession

Question 35:

Which two of the following options are benefits of the POST method (choose two)?
A. It is used for getting information such as a simple HTML page or the results of a database query.
B. It is a method that supports query strings of unlimited length.
C. It hides data because it isn't passed as a query string, but is passed instead in the message body.
D. It normally saves resources because of the way the request is compressed.

Question 36:

Which of the following methods belongs to the ServletContext class?
A. getInitParameterNames
B. getParameterValues
C. getParameterValues(String)
D. getInitParameter

Question 37:

The session scope includes which two of the following (choose two)?
A. Requests from several machines.
B. All hits from a single machine.
C. Multiple browser windows if they share cookies.
D. Multiple hits from the same browser across some period of time.

Question 38:

Which of the following methods corresponds to the HTTP PUT method?
A. getPUT
B. putHttp
C. httpPUT
D. doPut

Question 39:

Which method returns an enumeration of String objects containing the names of the parameters contained in the request or an empty enumeration if the request has no parameters?
A. getParameterNames
B. getMap
C. getParameterMap
D. getParameterValues

Question 40:

Read the following code:
< html >
< body >
Devyn likes < b >R/C Buggies< /b >. < br >
< %! int count = 100, factor=5; % >
< %=count * factor% >
< /body >
< /html >

Which two statements are true regarding this code (choose two)?
A. This is a JSP page, but it will not run because it is missing the JSP declaration.
B. The code will display: Devyn likes R/C Buggies. 500
C. This JSP page will be translated into servlet code, which will be compiled and invoked as a servlet going forward.
D. You can't declare two integers on the same line in JSP.

Question 41:

How do you get the absolute path for a given virtual path?
A. getabsolute Path(String path)
B. getPath(String path)
C. getPathabsolute (String path)
D. getPathabsolute ()

Question 42:

Which method do you use to retrieve multiple values for a given parameter?
A. getParameterValues
B. getParameterValues(String parameterName)
C. getParameters
D. getParameters(String parameterName)

Question 43:

How would you “print” a text message to the browser?
A. PrintWriter out = response.getWriter();
out.println(message);

B. response.println(message);

C. ServletOutputStream out = response.getWriter();
out.println(message);

D. ServletOutputStream out = response.ServletOutputStream();
out.println(message);K.

Question 44:

Which method obtains a resource located at the named path as an InputStream object?
A. getResourceStream(String path)
B. getResourceAsStream(String path)
C. getResource(String path)
D. getStream(String path)

Question 45:

A browser or application will sometimes send a request to a server just to check the status or get information (such as 'can you handle a file upload?') from the server. What method does it use to do this?
A. HEAD
B. PING
C. DELETE
D. POST

Question 46:

What does the getParameter(String) method do?
A. It returns the value of a request parameter.
B. This method is not valid. It really is getFormParameter.
C. It should be getParameter without a string parameter of its own.
D. It can be used to return an integer from a form field.

Question 47:

What happens if the container crashes?
A. The JVM calls finalize for all pending servlet requests.
B. Since it is crashing it doesn't do anything but disappear.
C. The destroy method is called if possible.
D. The log is noted and then pending requests get simple error returns.

Question 48:

The PUT type request is for which type of situation?
A. Uploading files to the server.
B. Submitting form field values.
C. Testing for valid URLs.
D. Using XML for exchanges.

Question 49:

Which of the following two options are ways to get a RequestDispatcher (choose two)?
A. getDispatcher
B. getDispatcherName
C. getNamedDispatcher
D. getRequestDispatcher

Question 50:

Which of the following two options are ways to invoke the doGet method (choose two)?
A. The init method calls doGet.
B. The container calls doGet.
C. The request object calls doGet.
D. The service method calls doGet.

Question 51:

Which method returns the values of a given request parameter as an array of strings, or returns null if the parameter does not exist?
A. getParameterMap
B. getParameterValues
C. getParameterValues
D. getParameters

Question 52:

What happens if you set a Web application-wide parameter through ServletContext, but don't provide a value?
A. This cannot happen.
B. An exception will be thrown.
C. Retrieving this parameter will return a string containing a servlet container version number.
D. Retrieving this parameter will return a string containing a servlet container name.

Question 53:

What is the most frequently used type of HTTP request?
A. POST
B. GET
C. DELETE
D. CALL

Question 54:

How do you get the request header names?
A. Enumeration e = request.getHeaderNames ;
B. String[] names = request.getHeaderNames ;
C. Enumeration e = request.getHeaders ;
D. String[] names = request.getHeaders ;

Question 55:

Suppose you want to open a binary file in a browser from a servlet. How would you declare and initialize the output stream?
A. ServletContext.getOutStream ;
B. ServletContext.getBinaryStream ;
C. ServletOutputStream out = response.getOutputStream ;
D. PrinterWriter out = response.getPrinterWriter ;

Question 56:

Please provide the interface name that allows you to make your servlet thread-safe.
_____________________________

Question 57:

How do you add the content-type header to the response?
A. response.setContentType ;
B. response.setType( contentType );
C. response.setContentType( String );
D. String type = request.getContentType ;

Question 58:

Which of the following two options are features of the GET method (choose two)?
A. It can handle most request types including file uploading and form submissions.
B. It is for getting information such as a simple HTML page or the results of a database query.
C. This method supports query strings. Servers usually limit query strings to about 1,000 characters.
D. This disallows bookmarks.

Question 59:

What happens if, when calling getParameterValues, the parameter has a single value?
A. It returns an error. You should use the getParameterValue method for single value parameters.
B. It returns an array with a length of one.
C. getParameterValues calls getValue for that single value.
D. It returns a string with that single value.

Question 60:

The POST type request is most often used for which of the following situations?
A. When uploading a file.
B. With query strings.
C. The POST request is a combination of a GET and PUT.
D. When submitting an HTML form.

Previous Chapter: Mock Exam 1 - Answers

Next Chapter: Mock Exam 2 - Answers

SCWCD Mock Exam 1

This chapter is the first of our 2 practice Exams. It contains 60 Questions and you can take upto 90 minutes to answer all of them.

Remember that the exam contains the same number of Questions ‘60’ and you will be given the same 90 minutes only. So, make sure you time yourself and don't use more than the allotted time.

Questions:

Question 1:

Regarding a typical HTTP request/response cycle, which of the following places the described events in their proper order? (Choose two.)
A. The Web browser makes an HTTP request, the Web server receives the request, and the Web server hands off the request to the servlet container.
B. A client responds to a servlet validation ping, Web server receives the request, and the Web server hands off the request to the servlet container.
C. The servlet container receives a request. The container reads the configuration (web.xml), and then calls the appropriate servlet.
D. The servlet polls the request object to find out what to do, the servlet performs its logic, and then sends data back to the client via the response object.

Question 2:

Which of the following are true about JSP comments? (Choose two.)
A. The JSP syntax is < % - - comment - - % >
B. The JSP syntax is < ! - - comment - - >
C. The XML syntax is < jsp: comment >< /jsp: comment >
D. They document the JSP page but is not inserted into the response.

Question 3:

Servlets are a required API of which Java 2 platform?
A. J2ME
B. J2SE
C. J2EE
D. J2DE

Question 4:

Which of following methods represents the servlet life cycle described in the API? (Choose three.)
A. init
B. start
C. service
D. destroy
E. getServletInfo

Question 5:

Which two of the following are true regarding the container initializing a servlet before it can handle requests from clients? (choose two)
A. The container calls the init method.
B. The container calls the service method.
C. This is how you can keep track of request activities.
D. This is how you set up a catch/try block.

Question 6:

During initialization, the servlet instance can throw which exceptions? (Choose two.)
A. ServletUnavailableException
B. UnavailableException
C. ServletNotFoundException
D. ServletException

Question 7:

Which of the following statements regarding the forward method of the RequestDispatcher interface are true?
A. It must be called before the response buffer is full.
B. It can throw an IllegalStateException exception.
C. It requires an absolute path. A relative path won't work.
D. The client must have this feature turned on.

Question 8:

If during initialization, the servlet instance throws an exception, which of the following statements is true regarding the destroy() method?
A. The method is called finalize().
B. The container calls the destroy() method.
C. The container invokes the catch block.
D. The container doesn't call the destroy method after an exception.

Question 9:

Which exceptions can a servlet throw during the service of a request? (Choose two.)
A. RequestException
B. ServletException
C. HttpException
D. UnavailableException

Question 10:

Which two of the following are true about page directives in JSP?
A. They define attributes that apply to an entire JSP page.
B. If a variable is declared it must appear before it used in the JSP.
C. You can declare instance variables with them.
D. There can only be one.

Question 11:

Which two statements are true regarding how the servlet container will keep a servlet loaded? (choose two)
A. A servlet instance may be kept active in a servlet container for the lifetime of the servlet container.
B. When the session ends, the servlet is unloaded.
C. The specification defines a session to have a default timeout of 20 minutes.
D. There is no association between how long a servlet is loaded and the session.

Question 12:

Before the servlet container may destroy a servlet, what must be true?
A. Pending requests are flushed.
B. HttpSession calls finalize().
C. ServletContext calls finalize().
D. Threads that are currently running in the service method of the servlet must complete execution.

Question 13:

Regarding container paths and URL, which of the following equations is always true?
A. requestURI = contextPath + servletPath + pathInfo
B. requestURI = contextPath + pathInfo + servletPath
C. contextPath = requestURI + servletPath + pathInfo
D. servletPath = contextPath + pathInfo

Question 14:

How do you include an outside resource into a JSP page?
A. < jsp: include page="salesTax.jsp" >
this works
< /jsp: include >

B. < jsp: include uri="salesTax.jsp"/ >

C. < jsp: include page="salesTax.jsp" >
< jsp: param name="state" value="CA" / >
< jsp: param name="amount" value="359.92" / >
< /jsp: include >

D. < jsp: include uri="salesTax.jsp" >
< jsp: param name="state" value="CA" / >
< /jsp: include >.

Question 15:

What information does the client send back as part of a cookie?
A. date, location, name, and value
B. name and value
C. location, name, and value
D. server version, date, and SSL status

Question 16:

What is the lifetime of the request object?
A. Until all threads associated with the session are complete.
B. This is container vendor specific.
C. Like garbage collection, exact timing is not specified.
D. It depends on the scope of a servlet's service method.

Question 17:

Which of the following are true about includes in JSP? (Choose two.)
A. There is no such thing.
B. The XML syntax is < jsp: text > < /jsp: text >
C. The JSP syntax is < %@ include file="relativeURL" % >
D. The JSP syntax is < % include("string") % >
E. The included text is added to the JSP page at translation time, when the JSP page is compiled.

Question 18:

What does a servlet container do with buffering? (Choose two.)
A. It is allowed to buffer output going to the client.
B. It is not required to buffer output going to the client.
C. It is required to buffer output going to the client.
D. The container can be configured to buffer in the buffer.xml configuration file.

Question 19:

Which of the following are true about the declarations in JSP? (Choose two.)
A. The JSP syntax is < %@ declaration % >
B. The JSP syntax is: < %! declaration % >
C. The XML syntax is < jsp: declare >< /jsp: declare >
D. The JSP syntax is < % declaration % >.

Question 20:

How do you write a message to the WebApp log?
A. Response.log()
B. ServletContext.log(String)
C. Response.errorLog()
D. ServletContext.logger()

Question 21:

Headers may contain data that represents which data types? (Choose two.)
A. int
B. String
C. Date
D. Object

Question 22:

Using the sendError method has what side effect? (Choose two.)
A. There is no way to catch errors after calling sendError.
B. It automatically calls the destroy method.
C. It commits the response.
D. It terminates the response.

Question 23:

Which two of the following methods terminate the response so that afterward no more output may be added to the response buffer? (choose two)
A. The sendError method.
B. The sendRedirect method.
C. The sendTerminate method.
D. The sendComplete.

Question 24:

Which two of the following are true regarding the Hypertext Transfer Protocol (HTTP)? (choose two)
A. It is a stateful protocol.
B. It is a stateless protocol.
C. Servlets use sockets to make it stateful.
D. Servlets can only handle real connections so it is the container vendor's responsibility to manage this.

Question 25:

Which of the follow are features of URL rewriting?
A. It converts relative to absolute paths.
B. It redirects clients to another URL.
C. It is used for sessions.
D. It appends to a query string.

Question 26:

When is a session considered established?
A. When a client joins it.
B. When you create a cookie on the client.
C. When the client is notified about the session.
D. When the request object is created.

Question 27:

Which of the following methods may be used to send error information back to a client? (Choose two.)
A. HttpServletError.setError()
B. HttpServletResponse.sendError()
C. HttpServletError.sendStatus()
D. HttpServletResponse.setStatus()

Question 28:

What is the correct syntax for assigning a value to a bean's property?
A. < jsp: property name="houseLotBean" property="id" value="33245" / >
B. < jsp: useBean name="houseLotBean" property="id" value="33245" / >
C. < jsp: setProperty name="houseLotBean" property="id" value="33245" / >
D. < jsp: setProperty property="id" value="33245" / >

Question 29:

Any object bound into a session is available to which other servlets?
A. Those servlets that share the same response.
B. Those servlets that have access to HttpSession.
C. Those servlets in the same container.
D. Those servlets that belong to the same ServletContext.

Question 30:

Some objects may require notification when they are placed into, or removed from, a session. This information can be obtained by having the object implement which interface?
A. HttpSessionListener
B. ServletContextListener
C. HttpSessionBindingListener
D. HttpServletResponseListener

Question 31:

When will the life of the session expire? (Choose two.)
A. When you call the expunge() method.
B. When you set the setMaxInactiveInterval to -1.
C. When you call the invalidate() method.
D. When the service method completes.

Question 32:

What are the methods of the RequestDispatcher interface? (Choose two.)
A. include
B. getClient
C. forward
D. back

Question 33:

Using XML syntax, how do you add text to the JSP output stream?
A. < jsp: page text="your text here" / >
B. < jsp: text >
your text
< /jsp: text >

C. < jsp: include param="text" value="your text here"/ >
D. < jsp: text value="text here"/ >

Question 34:

A servlet being used from within an include has access to which of the following? (Choose two.)
A. javax.servlet.include.response_uri
B. javax.servlet.include.context_path
C. javax.servlet.include.servlet_path
D. javax.servlet.include.cookie_info

Question 35:

Which of the following statements is true about how a servlet binds an object attribute into an HttpSession implementation by name?
A. This is determined by the deployment descriptor.
B. It depends on how you extend a servlet.
C. It depends on the container.
D. It binds it to the HttpServletResponse object.

Question 36:

The HttpServlet abstract subclass has which of the following methods beyond the basic Servlet interface? (Choose two.)
A. doHead()
B. doGet()
C. doRemove()
D. doCookie()

Question 37:

Which of the following elements are legal in a JSP scriptlet? (Choose two.)
A. Statements
B. Variable declarations
C. jsp: useBean
D. XML action

Question 38:

Fill in the name of the method of HttpServletResponse used to notify the client of a servlet error (without parentheses and parameters).
______________

Question 39:

Which of the following is true about template data in JSP?
A. The XML syntax is < jsp: template > < /jsp: template >
B. The XML syntax is < jsp: text > < /jsp: text >
C. The JSP syntax is < % expression % >
D. It is processed by the JSP engine.

Question 40:

Regarding changing the status in the response header, which statement is true?
A. You use the addStatus method.
B. You use the setStatus method.
C. You use the page directive.
D. You use an XML action directive.

Question 41:

Provide the name of the method that the servlet container calls on every request.
______________

Question 42:

Regarding the taglib directive, which of the following two statements are true?
A. It names the tag library that defines the custom tags and specifies their tag prefix.
B. It is the tag-library directive, not the taglib directive.
C. It declares that the JSP page uses custom tags.
D. It declares that the JSP page can use beans as defined in the directive.

Question 43:

What happens when the session attribute of the page directive is false? (Choose two.)
A. The session attribute doesn't go in the page directive.
B. You cannot use the session object.
C. Referring to a session object in the code causes a translation-time error.
D. The session attribute can only be specified with XML, not JSP syntax.

Question 44:

How do you specify that a given JSP page can be used as an error page?
A. There is no tag for this. It must be done in the web.xml configuration file.
B. Set the isErrorPage attribute of the page directive to true.
C. Place it in the error directory.
D. Use the include element.

Question 45:

Regarding a JSP page that inherits a class, which two of the following are true?
A. Servlets can inherit a class so JSP pages can too.
B. It uses the extends="package.class" attribute of the page directive.
C. It can only inherit another JSP page, not a servlet.
D. It can only inherit a JSP page with the same superclass.

Question 46:

Which statement is true about JSP expressions?
A. You must convert them to strings to append them to the output stream.
B. The JSP syntax is < % expression % >
C. The JSP syntax is < %=expression % >
D. The JSP syntax is < % System.out.print(expression) % >

Question 47:

Regarding forwarding a request to a Web resource in JSP, what two of the following are true?
A. You use the page directive. Set the forward attribute to true.
B. You can't do this in JSP. Do it at the servlet level.
C. < jsp: forward page="< %= expression % >" / >
D. < jsp: forward page="relativeURL" >
< jsp: param name="parameterName" value="parameterValue" / > +
< /jsp: forward >

Question 48:

Which of the following are true about the include directive and the jsp: include element?
A. The include directive is processed when the JSP page is translated into a servlet class. The jsp: include element is processed when a JSP page is executed.
B. The include directive is processed when the JSP page is compiled into a servlet class. The jsp: include element is processed when a JSP page is translated.
C. The include directive is processed when the JSP page is translated into a servlet class. The jsp: include element is processed when a JSP page is translated.
D. The include directive is processed when the JSP page is executed into a servlet class. The jsp: include element is processed when a JSP page is executed.

Question 49:

How can a servlet set headers of an HTTP response? (Choose two.)
A. Using a query string.
B. Using POST.
C. Using addHeader.
D. Using setHeader.

Question 50:

What kind of scheme is the HTTP protocol?
A. request/response
B. store/forward
C. queuing
D. search/return

Question 51:

If you wanted to use a conditional piece of code, which of the following shows where would you place it?
A. < jsp: scriptlet > code goes here < /jsp: scriptlet >
B. < jsp: code > code goes here < /jsp: code >
C. < jsp: include > code goes here < /jsp: include >
D. < jsp: jsp > code goes here < /jsp: jsp >

Question 52:

How would you forward a request to another resource?
A. < jsp: forward url="page.htm" / >
B. < jsp: forward param="page.htm"/ >
C. < jsp: forward uri="page.htm" / >
D. < jsp: forward page="page.htm" / >

Question 53:

What does the sendError method do?
A. It sends an error message to the server.
B. It sends an error message to the client log.
C. It logs an error.
D. It sends an error response to the client using the specified status.

Question 54:

Requests are represented by which two of the following objects? (choose two)
A. Request
B. Servlet Request
C. HttpServletRequest
D. ContainerRequest

Question 55:

Regarding passing an exception object to the method that writes information to the log file, which statement is true?
A. You can pass a string but not an exception object to the method that logs a message.
B. You can pass an exception object to the ServletContext.errorLog method that logs a message.
C. The exception must be converted to a string first.
D. You can use the response.log method to write to the log.

Question 56:

Which of the following will include the text of a resource at translation time?
A. < %@ include file="relativeURLspec" % >
B. < %! include file="relativeURLspec" % >
C. < %jsp: include file="relativeURLspec" % >
D. < %@ page import="relativeURLspec" % >

Question 57:

Which two of the following are correct uses of the RequestDispatcher (assume req is a correctly instantiated object of HttpServletRequest)? (choose two)
A. req.getRequestDispatcher(forwardURL). forward(req, res);
B. req.getRequestDispatcher(includeURL). include(req, res);
C. req.getRequestDispatcher.include(req, res);
D. req.getRequestDispatcher.forward(req, res);

Question 58:

What happens if you send data to the client after sendError has been called?
A. The information is ignored by the server.
B. The information is ignored by the client.
C. The method will throw IllegalStateException.
D. The method will throw IllegalSendException.

Question 59:

Which design pattern acts as a proxy and reduces network traffic?
A. Value objects
B. Model-view-controller
C. Data access objects
D. Business delegate

Question 60:

Regarding the sendRedirect method, which two of the following statements are true? (Choose two.)
A. It is legal to call the sendRedirect method with a relative URL path.
B. It is legal to call the sendRedirect method with an absolute URL path.
C. You must redirect to a servlet that implements the same interface.
D. You must redirect to a resource that must be defined in the deployment descriptor.

Previous Chapter: Chapter 59 - Exam Preparation Tips
© 2013 by www.inheritingjava.blogspot.com. All rights reserved. No part of this blog or its contents may be reproduced or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise, without prior written permission of the Author.

ShareThis

Google+ Followers

Followers