3
Free SCWCD Certification Practice Questions: What will be the output of the following JSP code? <html><body> <% int a = 10; %> <%! int a = 20; %> <%! int b = 30; %> The value of b multiplied by a is <%= b * a %> </body> </html> A) The code will not compile B) The value of b multiplied by a is 30 C) The value of b multiplied by a is 300 D) The value of b multiplied by a is 600 E) The value of b multiplied by a is 0 Consider the following code snippet of servlet code: public void doGet (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out = response.getWriter(); String dbValue = getValueFromDB (); if (dbValue == null) response.sendError (HttpServletResponse.SC_NOT_FOUND, "DB Lookup Failed"); out.println (dbValue); } If the getValueFromDB () method returns null , which of the following statements are true? A) The code will work without any errors or exceptions B) An IllegalStateException will be thrown C) An IOException will be thrown D) A NullPointerException will be thrown Let's assume you are developing a custom tag handler using the BodyTag interface. The BodyTag interface extends the IterationTag interface by defining additional methods that allow a tag handler to evaluate its body content in a temporary buffer. Upon execution, your tag handler returns the EVAL_BODY_BUFFERED return value from the doStartTag() method. In addition, your tag handler returns the EVAL_BODY_AGAIN value two times from the doAfterBody() method. Based on this information, how many times will the setBodyContent() method be called by the JSP container? A) Zero

Free SCWCD Certification Practice Questions

Embed Size (px)

Citation preview

Page 1: Free SCWCD Certification Practice Questions

Free SCWCD Certification Practice Questions:

What will be the output of the following JSP code?

<html><body> <% int a = 10; %> <%! int a = 20; %> <%! int b = 30; %> The value of b multiplied by a is <%= b * a %> </body> </html>

A) The code will not compile B) The value of b multiplied by a is 30 C) The value of b multiplied by a is 300 D) The value of b multiplied by a is 600 E) The value of b multiplied by a is 0

Consider the following code snippet of servlet code:

public void doGet (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out = response.getWriter(); String dbValue = getValueFromDB (); if (dbValue == null) response.sendError (HttpServletResponse.SC_NOT_FOUND, "DB Lookup Failed"); out.println (dbValue); } If the getValueFromDB () method returns null , which of the following statements are true? A) The code will work without any errors or exceptions B) An IllegalStateException will be

thrown C) An IOException will be thrown D) A NullPointerException will be thrown Let's assume you are developing a custom tag handler using the BodyTag interface. The BodyTag interface extends the IterationTag interface by defining additional methods that allow a tag handler to evaluate its body content in a temporary buffer.

Upon execution, your tag handler returns the EVAL_BODY_BUFFERED return value from the doStartTag() method. In addition, your tag handler returns the EVAL_BODY_AGAIN value two times from the doAfterBody() method.

Based on this information, how many times will the setBodyContent() method be called by the JSP container?

A) Zero B) One C) Two D) Three Let's assume you are deploying a legacy JSP page using a JSP container that complies with the JSP 2.0 specifications. In JSP 2.0, EL (Expression Language) constructs will be interpreted by default. However, you are concerned that this may cause problems for your legacy JSP application.

Which of the following can be used to configure the JSP container to ignore EL expressions? A) <%@ page isELIgnored="false" %> B) <%@ page isELIgnored="true" %> C) <%@

include isELIgnored="false" %> D) <%@ import isELIgnored="false" %> Let's assume you have a customerBean which has an address property object. This address object has a city property.

Which of the following is a valid way to set the city property of the customerBean.address object using the appropriate JSTL tags? A) <c:set target="${customerBean.address}" property="city" value = "${city}" /> B) <c:set property="customerBean.address" value="${city}" /> C) <c:set target="${customerBean}" property="address.city" value = "${city}" /> D) <c:set var="${customerBean.address}"

property="city" value = "${city}" /> Let's assume you are developing a web application. One of the requirements of this application is to design a flexible framework so that services can be easily added and removed without affecting existing components. For instance, services such as logging,

Page 2: Free SCWCD Certification Practice Questions

authentication, debugging, compressing and encoding output, etc.. should be "pluggable" without requiring changes to the core application code. Which of the following design patterns can be used in this situation? A) Intercepting Filter B) Transfer Object C) Business Delegate D) Data

Access Object Let's assume you are writing a JSP page using EL expressions. You have an variable declared as java.util.Map customerMap. You need to retrieve the customer info that is stored in this map.

Which of the following methods is invoked by the JSP engine upon execution of the following EL expression: ${customerMap[CustomerA]}? A) customerMap.get (pageContext.findAttribute ("CustomerA")); B) customerMap.get("CustomerA") C) customerMap.remove ("CustomerA"); D) customerMap.getProperty ("CustomerA"); E) customerMap.getCustomerA ();