aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Doubt in EL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Doubt in EL" Watch "Doubt in EL" New topic
Author

Doubt in EL

Padma priya Gururajan
Ranch Hand

Joined: Oct 05, 2006
Posts: 437
Hi,
10. public class MyBean {
11. private java.util.Map params;
12. private java.util.List objets;
13. private String name;
14. public java.util.Map getParams() { return params;}
15. public String getName() { return name; }
16. public java.util.List getObjects() { return objects; }
17. }


Which will cause errors(assume that an attribute name mybean can be found, and if of type MyBean)? (Choose all that apply)
A. ${mybean.name}
B. ${mybean["name"]}
C. ${mybean.objects.a}
D. ${mybean["params"].a
E. ${mybean.params["a"]}
F. ${mybean["objects"].a}

The answers are C and F.
Can you tell how they have arrived at this answer?
With regards,
Padma priya N.G.


Padma priya N.G.
Be the change you want to be - Mahatma Gandhi
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

You're asking a lot about fundamental EL since yesterday. Please read your book, and refer to the specification to understand how the "." and "[]" work. Then ask what you do not understand.
Please understand that your questions are difficult to answer, because they deal with fundamental things which take time to explain. You don't seem to have read anything about EL before asking.
JSP.2.3.4 Operators "[]" and "." from the specification will answer most of your questions.


[My Blog]
All roads lead to JavaRanch
Padma priya Gururajan
Ranch Hand

Joined: Oct 05, 2006
Posts: 437
Hi,
I am unable to understand why option 'F' is chosen as the correct answer?
With regards,
Padma priya N.G.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

Remember that a.b is the same as a["b"] ? C and F are the same. So if you understand C, you'll understand F You can only access a list via an index (integer), and "a" is not an index. When accessing a list, the container will try to call a.get(b), so b must be an integer.

(by the way, line 12 has a typo)
Padma priya Gururajan
Ranch Hand

Joined: Oct 05, 2006
Posts: 437
Hi,
Thanks.
With regards,
Padma priya N.G.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubt in EL