• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

doubt when compiler error and when exception generate in these questions

 
pradeep singh
Ranch Hand
Posts: 339
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Question 6. Given:

<%@ taglib uri="example" prefix="example" %>
<example:aTagWithBody>
<%="Body Content"%>
</example:aTagWithBody>

If the aTagWithBody handler extends from TagSupport and returns BodyTag.EVAL_BODY_BUFFERED from doStartTag(), what will the above page print?

Options are:
1.The tag handler class would not compile.

2.An exception at request time.
3."Body Content" will NOT be printied.
4."Body Content" will be printied.
5.None of these.

Answer is given 2.Why not 1.





Question 7. Consider the following JSP code:

<mylib:MyIterTag>
<%="Hello World"%>
</mylib:MyIterTag>

If the tag handler class for MyIterTag implements IterationTag and returns IterationTag.EVAL_BODY_BUFFERED from doStartTag(), what will be output in the response
options are given:
1.Hello World
2.<%="Hello World"%>
3.The tag handler will not compile.
4.The tag handler will compile but throw an exception at request time.
5.No compile-time or run-time erros and nothing will be printed in the output.

Answer is given :3. Why not 4.






I am confuse in these 2 questions .Don't know when compiler error arise and when exception arise.Please explain me in depth.


source:enthware
[ June 02, 2008: Message edited by: pradeep singh ]
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Question6 Answer is given 2.Why not 1.

The value returned by doStartTag() is an int, and BodyTag.EVAL_BODY_BUFFERED is an int. So the compiler will think that everything is fine.

Question7 3. Why not 4.

There is no EVAL_BODY_BUFFERED in IterationTag, thus compile error.

Don't know when compiler error arise and when exception arise.

Think about the things you learned in SCJP, about what a compiler error is. It should be easy enough to know when a compiler error occurs as long as you know the API involved. The problem is to remember the API
 
pradeep singh
Ranch Hand
Posts: 339
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Mr.Christophe Verre
 
java bangalore
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi pradeep singh ,

Can you tell me which book you studied for SCWCD...i plan to give the exam in 15 days time and have been going through David BridgeWater book.....can you suggest the books you went through and the mock exams you took....

this will be of great help...thanks.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"java bangalore",
You've already been warned here about the Naming Policy. Please adjust your name according to the policy.
 
raja ram
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

For the first Question why exception is thrown is that because of scriptlet
since scriplets are not allowed in the Tag Body am i correct if wrong what is the actual reason for the exception to be thrown.

Thanks
 
raja ram
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Any Updates on this.

Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic