Win a copy of Spark in Action this week in the Open Source Projects forum!
  • 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

question from SCWCD mock test

 
Ranch Hand
Posts: 231
Tomcat Server Notepad Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<html>
<body>
Result is ${"2" > 3}
</body>
</html>


a. Result is true
b. Result is false


correct ans is :: b

how can we compare a string literal with a number??
can EL automatically convert string into number??
 
Ranch Hand
Posts: 924
1
Netbeans IDE Fedora Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi ,

yes el treates "2" as integer for the comparison. you should keep few things in mind when you come across such questions

1. EL is not java.

2 el is forgiving. it will coerce the operands to fit into the context of operators.

there are vastly different number of combinations of such expressions possible in EL . the best way to do is to make a small program and play with such expressions. cook your own expression , see the results and then analyse it.

regards
Gurpreet
 
shivam singhal
Ranch Hand
Posts: 231
Tomcat Server Notepad Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks gurpeet ..
 
I suggest huckleberry pie. But the only thing on the gluten free menu is this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic