jQuery in Action, 3rd edition
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Mock Exam Question. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Mock Exam Question." Watch "Mock Exam Question." New topic

Mock Exam Question.

Gaurav Sahni
Ranch Hand

Joined: Sep 03, 2003
Posts: 56
Howdy CattlePeople !!!

Question from a mock exam:

Consider the tag handler class shown in exhibit.
What will be printed when the above tag is used as follows in a jsp page:

Hello <mylib:mytag> World!</mylib:mytag>

Select 1 correct option.

1. Hello

2. Hello World!

3. Hello In doAfterBody() World!

4. Hello In doAfterBody()

5. None of the above.

I ticked option 4, but the correct answer given was 1.
Anybody can help ?


To know recursion, you must first know recursion...
Ture Hefner

Joined: Nov 14, 2004
Posts: 18
This one is tricky. I think I am going to be doomed when I take the test.
MyTag extends TagSupport but it does not override the doStartTag() method. The return value for the default implementation of TagSupport.doStartTag() is SKIP_BODY.
Therefore, the body is skipped and the doAfterBody() method is never executed. After doStartTag() returns SKIP_BODY, the thread of execution proceeds directly to doEndTag(). The default implementation of TagSupport.doEndTag() returns EVAL_PAGE.

Sudhakar Guntaka
Ranch Hand

Joined: Nov 21, 2004
Posts: 46
hi gaurav,
i think option 1 is right because
1. if we dont override doStartTag() method, then its default return value is SKIP_BODY.
2. after this doAfterBody() method never executes (since return value for doStartTag() method is SKIP_BODY) and the control passes to doEndTag() method.
3. since we dont override doEndTag() method, its default return value is EVAL_PAGE.
4. so the code prints only Hello

Gaurav Sahni
Ranch Hand

Joined: Sep 03, 2003
Posts: 56
Thanx a lot Ture & sudhakar.
It clears my doubt.


P.S: Less than 24 hrs left for me to take the exam. Keeping finger's crossed.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: Mock Exam Question.
jQuery in Action, 3rd edition