Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Enthuware 1ZO-894 question - confused

 
Paul Statham
Ranch Hand
Posts: 60
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Edit: Ignore, it was me being stupid


So the question says


Given:

<%
Map m = new HashMap();
m.put("m", "n");
m.put("n", "o");
m.put("o", "p");
pageContext.setAttribute("map", m, PageContext.PAGE_SCOPE);
%>

Which of the following will output p? (choose 2)

A. ${map.(map.n)}
B. ${map[map[n]]}
C. ${map.o}
D. ${map(map(n))}
E. ${map.map.n}
F. ${map["o"]}


Answers are C+F, I'm confused by C.

The . operator is reserved for attributes and java beans, yes map is an attribute but it references a map object?
 
Trieu Duong Nguyen
Greenhorn
Posts: 18
Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I can analyze the C and F answers for you as following:

C. ${map.o} Correct

After the . "Dot" operator, it can be followed by map key or bean property.
And in [] , It can be followed by [same as dot] and index of collection or Array


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic