OCEJWCD 6 Mock Exam – 3

1 . Regarding the processing of a BodyTag handler,in which of the following cases a BodyContent object will be “pushed” into the pageContext?

  1. If the doStartTag() returns EVAL_BODY_INCLUDE
  2. If the doStartTag() returns EVAL_BODY_BUFFERED
  3. If the doStartTag() returns SKIP_BODY
  4. If the doStartTag() DOES NOT return SKIP_BODY
  5. A BodyContent object it is always created and pushed no matter what doStartTag() returns

2 . Which of the following apply to Transfer Object design pattern?

  1. It increases complexity by increasing the number of remote interfaces
  2. It increases network performance by introducing one coarse grained remote call for multiple finer grained network calls
  3. It reduces network traffic by introducing one coarse grained remote call for multiple finer grained network calls
  4. It increase server throughput by utilizing the CPU better
  5. It increases design overhead due to versioning issues

3 . Which of the following deployment descriptor snippets would you use to declare the use of a tag library?

1. <tag-lib>




2. <taglib>




3. <taglib>




4. <taglib>




5. <taglibmap>




Choose the one below:

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5

4 . Which of the following design patterns is used to separate the task of writing the GUI screens and business logic?

  1. View Logic
  2. Front Controller
  3. Model View Controller
  4. Business View
  5. Business Delegate

5 . For this jsp code to compile and run which of the given options should be true?

 <jsp:useBean class="com.bookstore.Book" type="java.lang.Object" id="book" />

Choose the one below:

  1. This statement is wrong as type attribute is invalid
  2. Book must have a public no args constructor
  3. Book must have a public constructor but there is no requirement on arguments
  4. Book must have a public getInstance() method
  5. This statement will always throw an exception at runtime no matter what you do to Book class

6 . Your servlet may throw IOException while processing a request.You want to define an error page in your deployment descriptor so that whenever IOException is thrown,this page is serviced to the browser?
Which of the following XML fragments correctly specify the mapping?

1. <error-page>




2. <error-page>




3. <error-page>




4. <error-page>




5. <exception>




Choose the one below:

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5

7 . Select the tag that comes directly under the tag of a web.xml and that is used to specify a class whose object will be sent notifications when changes occur to the SevletContext?

  1. servlet-context-listener
  2. listener
  3. context-listener-class
  4. listener-class
  5. context-listener

8 . Consider the following JSP code (See exhibit)?
What will it print for the very first request to this page as well as the web application that contains this page?



    Integer count = (Integer) request.getSession(false).getAttribute("count");

    if(count != null )




    else request.getSession(false).setAttribute("count", new Integer(1));




Choose the one below:

  1. It will print Hello!
  2. It will print Hello and will set the count attribute in the session
  3. It will throw a NullPointerException at request time
  4. It will not compile

9. The following line of code exists in the doGet method of Servlet:

String sid = request.getParameter("jsessionid");

Which of the options will retrieve the HttpSession associated with the request?
(Assume that the session has already been created.)

Choose the one below:

  1. HttpSession session = request.getSession();
  2. HttpSession session = HttpSession.getSession(sid);
  3. HttpSession session = request.getSession(sid);
  4. HttpSession session = request.getSession(true);
  5. HttpSession session = request.getSession(false);


1 : 3 is correct.

2 : 2 & 3 is correct.

3 : 3 is correct.

4 : 2 is correct.

5 : 2 is correct.

6 : 4 is correct.

7 : 2 is correct.

8 : 2 is correct.

9 : 1,4 & 5 is correct.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>