Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
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

Mock Exam qs...

 
Poonam Akash
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What will be the correct choice ?
[code]
<%int x=0;%>
<% x = x + 1999; %>
Set it to: <%= x %>
[code]
What should be the initial value of x to allow
compilation to succeed, and allow the output of
"Set it to: 2000"?
Ans:A <% int x = 1 %>
B <%@ int x = 1 %>
C <%! int x = 1 %>
D None of the above
I think the correct choice should be 'C'.
What do u think?
Bye,
 
jawwad ahmed
Ranch Hand
Posts: 179
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well correct answer is d).since it should be.
<%!int a=1;%>(semicolon)
<%int a=1;%>(semicolon)
 
Ramu Kalvakuntla
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Even if its defined <%! int x = 1;%> still the answer will be d(none of the above). Because if you have a varibale defined at the class level and also at method level with the same name and if you access in the method with out this.x it will return the local varibale.
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
i agree with Ramu.
regards
maulin.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic