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

obfuscation level !!!

 
Niranjan Deshpande
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Consider the following code:
<html><body>
<jsp:useBean id="address" class="AddressBean" scope="session" />
state = <jsp:getProperty name="address" property="state" />
</body></html>
Which of the following are equivalent to the third line above? (Select three)
a <% state = address.getState(); %>
b <% out.write("state = "); out.print(address.getState()); %>
c <% out.write("state = "); out.print(address.getstate()); %>
d <% out.print("state = " + address.getState()); %>
e state = <%= address.getState() %>
f state = <%! address.getState(); %>

Answers: b, d, and e
Explanation

The third line in the code prints "state = " followed by the actual value of the property in the output HTML. Answer a is incorrect, because it is inside a scriptlet and does not print any output. Answer c is incorrect because the standard convention that the beans follow is to capitalize the first character of the property´┐Żs name. Therefore, it should be getState() and not getstate(). Answer f is incorrect because the method call address.getState() is in a declaration instead of an expression. Answers b, d, and e all do the same thing and are all equivalent to the third line of the code.

just see the bold part ! i never gave attention to it. and flunked the question !

so, is such obfuscation level in the real exam ?
 
Dinuka Arsakularatne
Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i found around 2-3 questions of that sort in the real exam. i marked them for the second round and only caught those small things in the second round. so if you are not sure of any answer just answer it and mark it before proceeding to the next questions. but this method can backfire as well. because sometimes when you look at the question again you may try to think in a different perspective resulting in you changing your correct answer to a wrong one... so use this method cautiously. but it really did help me because i only caught the tricky part in the second time i viewed the question.
 
Celinio Fernandes
Ranch Hand
Posts: 549
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
interesting. thanks for sharing.
 
Niranjan Deshpande
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


i flunked one question in SCJP exam because of this.
else i woulf have had got only 2 questions incorrect.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic