Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Mock exam questions

 
Senthil Kumar N
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

The question from Jwebplus

<%
request.setAttribute("names", new String[]{ "A", "B", "C" } );
request.setAttribute("index", "1");
%>
<h1><!-- insert code here --></h1>
Which of the following statements will print B in inserted in the above JSP page?

Select 3 correct options
a ${names.1}
b ${names[1]}
c ${names.index}
d ${names[index]}
e ${names.$index}
f ${names[$index]}

ans given is b,c,d

while I try the code for ${names[1]} and d ${names[index]} i am getting the expected result but for ${names.index} i am getting the error message as

" The "." operator was supplied with an index value of type "java.lang.String" to be applied to a List or array, but that value cannot be converted to an integer. "

Can anybody tell what are the correct option for this questions?

Thanks
 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Option "C" is incorrect. The . operator require Map or JavaBean at the left side. The right hande side should be the Map key or Bean Property.

Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic