This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
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
Author

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 ?


Regards,
Gaurav.


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

Joined: Nov 14, 2004
Posts: 18
Gaurav,
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.


Ture
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

regards,
sudhakar.
Gaurav Sahni
Ranch Hand

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



Regards,
Gaurav.

P.S: Less than 24 hrs left for me to take the exam. Keeping finger's crossed.
 
Don't get me started about those stupid light bulbs.
 
subject: Mock Exam Question.