Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Question 43)

 
Timber Lee
Ranch Hand
Posts: 157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which jsp lines are correct?
1) <%! String myString=”Hello” %>
2) <% String myString=request.getServerName() %>
3) <%= out.print(“Hello” %>
4) <%= “Hello” %>
author's answer is only 4) . do you think so?
 
g madhava
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1)<%! String myString=”Hello” %>
It needs to have a ; at the end like this
<%! String myString=”Hello”; %>
2) <% String myString=request.getServerName() %>
Same as above the ; is missing
3) <%= out.print(“Hello” %>
<%= means out.print so esssentially
it would be
out.print(out.print("Hello"));
which is not the way how it should be...
4) <%= “Hello” %>
This is the correct one as given by the author.
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!