Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

uestion ID :997027961920

 
Win Yu
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
uestion ID :997027961920
Which of the following is/are correct JSP scriptlet(s)?
1.
<% int i = 10; %>
System.out.println("starting loop");
<%for(i=0; i< 10; i++) { out.println(i); } %>
2.
<% int i = 0; %>
<% System.out.println("starting loop");%>
<% for(int i=0; i< 10; i++) { out.println(i); } %>
3.
<% int i = 0, s = 0;
System.out.println("starting loop");
for(; i< 10; i++) { s+=i; } %>
4.
<%
System.out.println("starting loop");
for(int i=0; i< 10; i++) {%> looping <%} %>
I think 2 is correct too.Any comment?
 
Win Yu
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got "Variable 'i' is already defined in this method.
for(int i=0; i< 10; i++) { out.println(i); }" error. so 2 is not correct.
^
 
sridhar satuloori
Ranch Hand
Posts: 144
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nope 2 is wrong as it is declaring i two times
All the others are correct, any comments
Sridhar

Originally posted by Win Yu:
I got "Variable 'i' is already defined in this method.
for(int i=0; i< 10; i++) { out.println(i); }" error. so 2 is not correct.
^

 
zoe dude
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
1,3,4 r prefect from syntax point of view.No error ,but on 3 option,a blank page will come.that's it.
Regards
Zoe
[This message has been edited by zoe dude (edited November 21, 2001).]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic