• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

obfuscation level !!!

 
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 ?
 
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.
 
Ranch Hand
Posts: 563
Google Web Toolkit Eclipse IDE 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.
 
If you believe you can tell me what to think, I believe I can tell you where to go. Go read this tiny ad!
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic