• 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Mock exam questions

Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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?

Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.

With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic