
_________________________________________________ī
Pleaseīwriteīyourīonītheītopīofītheīpage.ī
22c:21īComputerīīScienceīII:īDataīStructuresī
Quizī2Bī(openībookīandīnotes;īpleaseīcircleīallītheīcorrectīsolutions)ī
ī
1.īWhichīofītheīfollowingīisīincorrect?ī
A.īint[]īaī=īnewīint[2];ī
B.īintīa[]ī=īnewīint[2];ī
C.īint[]īaī=īnewīint(2);ī
D.īintīaī=īnewīint[2];ī
E.īintīa()ī=īnewīint[2];ī
ī
2.īīHowīmanyīelementsīareīinīarrayīdouble[]īlistī=īnewī
double[5]?ī
A.ī4ī
B.ī5ī
C.ī6ī
D.ī0ī
ī
3.īīAnalyzeītheīfollowingīcode.ī
publicīclassīTestī{ī
īīpublicīstaticīvoidīmain(String[]īargs)ī{ī
īīīīint[]īxī=īnewīint[3];ī
īīīīSystem.out.println("x[0]īisī"ī+īx[0]);ī
īī}ī
}ī
A.īTheīprogramīhasīaīcompileīerrorībecauseītheīsizeīofī
theīarrayīwasn'tīspecifiedīwhenīdeclaringītheīarray.ī
B.īTheīprogramīhasīaīruntimeīerrorībecauseītheīarrayī
elementsīareīnotīinitialized.ī
C.īTheīprogramīrunsīfineīandīdisplaysīx[0]īisī0.ī
D.īTheīprogramīhasīaīruntimeīerrorībecauseītheīarrayī
elementīx[0]īisīnotīdefined.ī
ī
4.īHowīcanīyouīinitializeīanīarrayīofītwoīcharactersītoī'a'ī
andī'b'?ī
A.īchar[]īcharArrayī=īnewīchar[2];īcharArrayī=ī{'a',ī'b'};ī
B.īchar[2]īcharArrayī=ī{'a',ī'b'};ī
C.īchar[]īcharArrayī=ī{'a',ī'b'};ī
D.īchar[]īcharArrayī=īnewīchar[]{'a',ī'b'};ī
ī
5.īīAssumeīint[]īscoresī=ī{1,ī20,ī30,ī40,ī50},īwhatīvalueī
doesījava.util.Arrays.binarySearch(scores,ī3)īreturn?ī
A.ī0ī
B.īā1ī
C.ī1ī
D.ī2ī
E.īā2ī