• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Epractice Lab mock exam 3 about [] operator

 
Himai Minh
Ranch Hand
Posts: 1359
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

The [] operator of JSTL is used to access which of the following.
[ Choose four ]

a. Array
b. Java Bean properties
c. Collection
d. Map
e. List

Choice A, Choice C, Choice D and Choice E are correct


The collection access operator [] can be used for accessing map, list, collection, array, properties, and Java bean objects. The property access operator '.' can only be used for accessing properties.



I think [] can be used to access Java bean properties, like ${person["name]"} (assume person is a bean and name is the property).
So, I think all of the options are correct.
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2531
112
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not sure about answer C: Collection. The specs mention Maps and Lists explicitly, but not a Set.

Did you try it?
 
Himai Minh
Ranch Hand
Posts: 1359
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Frits,

It works.

But I don't think HashSet will work. Set does not use index or key for each object in its collection.
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2531
112
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you try a Set?
 
Himai Minh
Ranch Hand
Posts: 1359
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Frits,
this is what I tried and the exception I got:


javax.el.PropertyNotFoundException: Property 'Hibernate' not found on type java.util.HashSet
javax.el.BeanELResolver$BeanProperties.get(BeanELResolver.java:259)
javax.el.BeanELResolver$BeanProperties.access$300(BeanELResolver.java:236)
javax.el.BeanELResolver.property(BeanELResolver.java:346)
javax.el.BeanELResolver.getValue(BeanELResolver.java:95)
...
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2531
112
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, that is what I expected.

Option C is wrong because not all Collections can use the [] operator.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic