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

doubt in a mock question?

 
pradeep singh
Ranch Hand
Posts: 339
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Question 1:Given the following statements, which of the EL expressions will evaluate to true?

request.setAttribute("none", "");

request.setAttribute("x", "10");

request.setAttribute("i", "01");

session.setAttribute("v", "05");

OPTIONS
1. ${" " gt -1}

2 ${none gt -1}

My question is why option 1 is wrong even if 2 is right.none is also an empty string.
Given answer is 2 option not 1.




source is enthware mock exam.
 
Garlapati Ravi
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. ${" " gt -1}

This throws : java.lang.NumberFormatException: empty String
none is also an empty string.

No. This is not an empty String. request.setAttribute("none", "");
there is no space between double quotes("")

request.setAttribute("none", " "); //space between double quotes
This doesn't work. It behaves same as ${" " gt -1}

even below doesn't work :
${" " + -1} // space between quotes, it treats " " as string.

if we remove the space, then it works, below works fine:
${"" + -1} // it treats "" as 0(zero)
[ May 30, 2008: Message edited by: Garla Ravi ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic