wood burning stoves 2.0*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes EL Query Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "EL Query" Watch "EL Query" New topic
Author

EL Query

Aditi Kamra
Greenhorn

Joined: Aug 25, 2009
Posts: 7
Hi,
i came across below two questions

1.What is the output of this page? (1 correct answer)
<html>
<body>
Result is ${"a" < "b"}
</body>
</html>
a.“Result is true”
b.“Result is false”

2.What is the output of this page? (1 correct answer)
<html>
<body>
Result is ${a < b}
</body>
</html>
1.“Result is true”
2.“Result is false”

Can anyone please explain the difference/answers to both of them

the answers are 1.(a) 2. (b)

Thanks ..
Pramod P Deore
Ranch Hand

Joined: Jul 15, 2008
Posts: 629

Hello Aditi,

1.What is the output of this page? (1 correct answer)
<html>
<body>
Result is ${"a" < "b"}
</body>
</html>
a.“Result is true”
b.“Result is false”

I think it gives output as "true" because it may compares the ascii values of characher a and b, as they are declared in double quote or single quote, but I am not sure.



2.What is the output of this page? (1 correct answer)
<html>
<body>
Result is ${a < b}
</body>
</html>
1.“Result is true”
2.“Result is false”


here it gives output "false" may be because here both a and b are null. ckeck it above for " Result is ${a==b)" it may give "true" because here both are null.

But i am not sure about both answers.

Life is easy because we write the source code.....
Chinmaya Chowdary
Ranch Hand

Joined: Apr 21, 2008
Posts: 432
Hi Aditi.
In EL compares lexicographically, here 'true' is correct.

In while evaluating, EL chooses is there any attribute(a) associates with any scopes(like page, request, session, application) if found returns it, if not EL treats it as 'false' (since this is logical expression). After that it chooses attribute (b), since it is not available, it returns 'false'. Then evalates, "false < false" it returns 'false'.

For more information see coercions rules.
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9291
    
  17

Aditi please Quote Your Sources when you post a question...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: EL Query
 
Similar Threads
What does flushing buffer means
again accessing map values in EL
@page session=false. request.getSession() throws error?
Niko's exam doubt
EL expressions