• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Mock exam questions

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic