SCWCD-10

04/14/2008

6 Comments

 

What will be the output of the following JSP code?

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

·  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

Answer
C
Since the local variable "a" has precedence over the global variable "a", the expression (b * a) evaluates as (30 *10), which equals 300

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");
response.sendRedirect ("Form.jsp"); }
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

Answer
B

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

Answer
B
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" %>

Answer
B

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}" />

Answer
A

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, 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

Answer
A

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 ();

Answer
A

What will be the output of the following JSP page?
 <html><body>
   <% a = 100; %>
   <% int a = 200; %>
   <%! int a = 300; %>
   a = <%= a %>, <%= this.a %>
 </body></html>

A) a = 200, 100
B) a = 300, 100
C) a = 100, 200
D) a = 200, 300
E) The code will not compile as written

Answer
A

Which of the following files is the correct name and location of deployment descriptor of a web application. Assume that the web application is rooted at \doc-root. Select the one correct answer ?  
 
     A    \doc-root\dd.xml       
     B    doc-root\web.xml       
     C    \doc-root\WEB-INF\web.xml       
     D    \doc-root\WEB_INF\web.xml       
     E    \doc-root\WEB-INF\classes\web.xml

Answer
C

Which element of the deployment descriptor is used to specify the class of the Servlet. ?  
 
     A    <servlet-class>       
     B    <servlet-name>       
     C    <servlet_name>       
     D    <servlet_class>       
     E    <servlet>
Answer
A

 


Comments

09/16/2010 17:53

Love is ever the beginning of knowledge as fire is of light.

Reply
09/17/2010 17:56

You know it's easier to get killed by a terrorist than get married over the age of 40.《Sleepless in Seattle》

Reply
09/28/2010 21:07

How can have ability dominated his sentiment? ? ?

Reply
10/06/2010 20:23

An American has no sense of privacy. He does not know what it means.There is no such thing in the country.

Reply
12/10/2010 21:51

To accomplish their dreams and efforts to fight!And do our best to improve this problem

Reply
01/10/2011 17:22

We realize the true worth of happiness when we are in sorrow.

Reply



Leave a Reply

    SCWCD Sets


    Archives

    May 2008
    April 2008