Test Yourself on SCWCD Exam #CX-310-081

Posted on
Share on Google+Share on LinkedInShare on FacebookShare on RedditTweet about this on TwitterEmail this to someone

Whizlabs, a leader in IT certification exam preparation, recently launched the Exam Simulator for the Sun Certified Web Component Developer 1.4 certification exam. The following quiz is an excerpt from Whizlabs Exam Simulator. For a detailed version, visit www.whizlabs.com/products/scwcd/scwcd.html.

1. A Web application prefers to use cookies for storing the user name. Identify all the possible methods that can be used to set the cookies. (Select two choices.)



  1. HttpServletResponse.setCookie (String name, String value)
  2. HttpServletResponse.addCookie (Cookie aCookieObject)
  3. HttpServletResponse.setCookie (Cookie aCookieObject)
  4. HttpServletResponse.addCookie (String name, String value)
  5. HttpServletResponse.setHeader (String name, String value)


2. What will be the result of an attempt to access this jsp page?


<% x=10; %>
<% int x=5; %>
<%! int x; %>
x= <%=x%>
x= <%=page.x%>



  1. Code does not compile because x is used before declaration.
  2. Prints x=5 followed by x=10
  3. Prints x=10 followed by x=5
  4. Prints x=10 followed by x=0
  5. None of the above.


3. Which of the following methods can return the SKIP_PAGE constant?



  1. doStartTag()
  2. doAfterBody()
  3. doEndTag()
  4. release()


4. You need to create a database connection in your application after reading the username, password and database server URL from the deployment descriptor. Which of the following will be the best place to do this?



  1. Servlet constructor
  2. init method
  3. service method
  4. doGet method
  5. doPost method


5. Which of the patterns, when used together, will result in a client-side business abstraction and abstraction of network details? (Select two.)



  1. Business Delegate
  2. Transfer Object
  3. Service locator
  4. Service Activator
  5. Intercepting filter
  6. Front Controller


6. Which of the following methods is used to retrieve initialization parameters of a Web application?



  1. String ServletContext.getInitParamater (String name)
  2. Object ServletContext.getInitParamater (String name)
  3. String ServletContext.getAttribute (String name)
  4. Object ServletContext.getAttribute (String name)
  5. String ServletContext.getParameter (String name)
  6. Object ServletContext.getParameter (String name)


7. Suppose there are two sessions, session1 and session2. In the deployment descriptor, you set the <session-timeout> element by 10, but you have called the method setMaxInactiveInterval (10) on session1. What will be the effect?



  1. Both the sessions will expire within 10 minutes.
  2. Both the sessions will expire after 10 seconds.
  3. Session1 will expire within 10 minutes, and session2 will expire within 10 seconds.
  4. Session1 will expire within 10 seconds, and session2 will expire within 10 minutes.


8. Which of the following statements is not true? (Select one.)



  1. The container invokes the release() method on a tag handler object, when it is no longer required.
  2. The setPageContext() method is the first method, which is called in a custom tag lifecycle.
  3. The doAfterBody() is the only method defined by the IterationTag interface.
  4. The setBodyContent() method is called only if the doStartTag() method returns EVAL_BODY_INCLUDE or EVAL_BODY_RETURNED.


9. In the following code fragment, the custom tag <WhizTags:course> is used to print the value of “example” attribute.


<WhizTags: course example= “The ${‘${‘}expr} is an EL expression”>


Which of the following is the behavior of this fragment?



  1. Prints “The ${expr} is an EL expression”
  2. Prints “The ${‘${‘}expr} is an EL expression”
  3. Compilation error as ${ is nested and a quote (‘) is missing
  4. Nothing is displayed as EL returns a null since the variable expr is undefined


10. Which of the following design patterns introduces an additional layer between the client and the service?



  1. Business Delegate
  2. Intercepting filter
  3. Front controller
  4. Service Locator


11. Which of the following is true about security in Web applications?



  1. Declarative security is not applicable in the case of include and forward actions.
  2. If no <http-method> element is present within a <security-constraint> element, the constraint does not apply to any of the HTTP methods.
  3. The HTTP Digest mechanism requires a certificate from a certification authority.
  4. Form-based authentication is more secure than the HTTP basic authentication.


12. Given the following servlet mappings in the deployment descriptor,


<url-pattern>/my/my/* </url-pattern>


<url-pattern>/my/my/a.b </url-pattern>


<url-pattern>/my/my/* </url-pattern>


Which of the following servlets will serve the request /test/my/my/a.b?



  1. FirstServlet
  2. TestServlet
  3. MyServlet
  4. None of the above


13. Which of the following listeners are not configured in the deployment descriptor? (Select two.)



  1. ServletContextListener
  2. ServletContextAttributesListener
  3. HttpSessionAttributeListener
  4. HttpSessionActivationListener
  5. HttpSessionBindingListener
  6. HttpSessionListener


14. Identify the output of the following jsp page.


String s = “2”;



  1. 6
  2. 4
  3. 2+4
  4. A Compilation error since an integer addition is performed with a String parameter.


15. What will be the output of the following JSP page? Assume that in the session, “userName” has a value “pippo”.


<%@ page import=“java.sql.*” is ELIgnored=“true” session=“false” %>
String userName =(String) session.getAttribute(“userName”);
Welcome {userName}



  1. Page fails to compile
  2. The page outputs “Welcome pippo”
  3. The page outputs “Welcome {pippo}”
  4. Page compiles and runs, but nothing is printed


16. A Tag Library Descriptor (TLD) is an XML document that describes a tag library. A TLD contains information about a library as a whole and about each tag contained in the library. The root of a TLD is the taglib element. One of the subelements of taglib element is the tag element. Which of the following is not a valid subelement of the tag element?



  1. name
  2. tag-class
  3. body-content
  4. description
  5. tag-id


17. You declare a bean in your JSP with id=“yourBean”. How would you get a bean property named “myProperty”?



  1. <jsp:getProperty id=“yourBean” property=“propertyName”/>
  2. <jsp:getProperty name=“yourBean” property=“propertyName”/>
  3. <jsp:getProperty beanId=“yourBean” property=“propertyName”/>
  4. <jsp:getProperty bean=“yourBean” property=“propertyName”/>


18. Which of the following JSTL core tags can be used to include the contents from external Web sites?



  1. c:include
  2. c:import
  3. c:fetch
  4. c:geturl
  5. c:forward
  6. None of the above


19. Which of the following i

Share on Google+Share on LinkedInShare on FacebookShare on RedditTweet about this on TwitterEmail this to someone


Posted in Archive|