Page 1 of 1
About Question enthuware.jwpv6.2.620 :
Posted: Fri Sep 09, 2011 6:52 am
by ETS User
Code: Select all
String[] numbers = new int[]{ "1", "2", "3", "4"}
String index = "2";
What would the following EL expression print?
The correct answer specified by ETSViewer: 3
How can it be "3", if this code will not compile?

1) int[] cannot be cast to String[]
2) no semi-colon after int[] array init;
P.S.: please, upgrade confirmation code generator! i have failed to correctly read it dosen times!

Re: About Question enthuware.jwpv6.2.620 :
Posted: Sat Sep 10, 2011 10:09 am
by admin
You are right new int should be replaced with new String. This has now been fixed.
thanks for your feedback!
BTW, if you signup on the forum, you will not be required to enter the code.
HTH,
Paul.
Re: About Question enthuware.jwpv6.2.620 :
Posted: Tue Apr 09, 2013 12:54 pm
by sebastien
Hello,
just one point, we need a semicolon after : String[] numbers = new String[]{ "1", "2", "3", "4"} no?
or it will not compile
Re: About Question enthuware.jwpv6.2.620 :
Posted: Tue Apr 09, 2013 7:24 pm
by admin
Yes, semicolon should be there. It will still not compile though because it is not the complete contents of the file

-Paul.
Re: About Question enthuware.jwpv6.2.620 :
Posted: Mon Feb 24, 2014 4:59 pm
by thituba20
Hello Guys,
This question speaks that answer is 3, but I made a test and the results was 4.
Have anybody tested this question in compilation?
Please, Could anybody make the test too?
Code: Select all
String[] numbers = new String[]{ "1", "2", "3", "4"}; String index = "2"; What would the following EL expression print? ${numbers[numbers[index-1]]}
Best Regards,
Thiago
Re: About Question enthuware.jwpv6.2.620 :
Posted: Mon Feb 24, 2014 8:36 pm
by admin
It prints 3.
Re: About Question enthuware.jwpv6.2.620 :
Posted: Thu Nov 27, 2014 4:37 pm
by johnlamb
Hi,
The explanation says:
${numbers[numbers[index-1]]} resolves to ${numbers[numbers[1]]}, which resolves to ${numbers[2]}, which is 3.
Should it say:
${numbers[numbers[index-1]]} resolves to ${numbers[numbers[1]]}, which resolves to ${numbers["2"]}, which is 3.
as numbers[1] is the string 2?
Re: About Question enthuware.jwpv6.2.620 :
Posted: Sat Nov 29, 2014 10:34 pm
by admin
You are right. It should be "2". Fixed.
thank you for your feedback!