QUESTION1Youhavealotofitemsthatneedtobeprocessed.Foreachitem,youneedtoperformacomple xcalculation.Whichtechniqueshouldyouuse? A.YoucreateaTaskforeachitemandthenwaituntilalltasksarefinished.B.YouuseParallel.Fortoprocessa llitemsconcurrently.C.Youuseasync/awaittoprocessallitemsconcurrently.D.YouaddallitemstoaBlock ingCollectionandprocessthemonathreadcreatedbytheThreadclass.CorrectAnswer:BQUESTION2Yo uarecreatingacomplexquerythatdoesn’trequireanyparticularorderandyouwanttorunitinparallel.W hichmethodshouldyouuse? A.AsParallelB.AsSequentialC.AsOrderedD.WithDegreeOfParallelismCorrectAnswer:AQUESTION3Y ouareworkingonanASP.NETapplicationthatretrievessomedatafromanotherwebserverandthenwrit estheresponsetothedatabase.Shouldyouuseasync/await? A.No,bothoperationsdependonexternalfactors.Youneedtowaitbeforetheyarefinished.B.No,inaser verapplicationyoudon’thavetouseasync/await.It’sonlyforresponsivenessontheclient.C.Yes,thiswillf reeyourthreadtoserveotherrequestswhilewaitingfortheI/Otocomplete.D.Yes,thisputyourthreadto sleepwhilewaitingforI/Osothatitdoesn’tuseanyCPU.CorrectAnswer:C QUESTION5Youneedtoimplementcancellationforalongrunningtask.Whichobjectdoyoupasstotheta sk? A.CancellationTokenSourceB.CancellationTokenC.BooleanisCancelledvariableD.VolatileCorrectAn swer:BQUESTION6Youareimplementingastatemachineinamultithreadedclass.Youneedtocheckwh atthecurrentstateisandchangeittothenewoneoneachstep.Whichmethoddoyouuse? A.Volatile.Write(refcurrentState)B.Interlocked.CompareExchange(refcurrentState,refnewState,ex pectedState)C.Interlocked.Exchange(refcurrentState,newState)D.Interlocked.Decrement(refnewS tate)CorrectAnswer:BQUESTION7Youneedtoiterateoveracollectioninwhichyouknowthenumbero fitems.Youneedtoremovecertainitemsfromthecollection.Whichstatementdoyouuse? A.switchB.foreachC.forD.gotoCorrectAnswer:CQUESTION8Youhavealotofchecksinyourapplication fornullvalues.Ifavalueisnotnull,youwanttocallamethodonit.Youwanttosimplifyyourcode.Whichtec hniquedoyouuse?A.forB.ConditionaloperatorC.Null‐coalescingoperatorD.Theshort‐ circuitingbehavioroftheandoperatorCorrectAnswer:DQUESTION9 Youareprocessingsomedatafromoverthenetwork.YouuseaHasNextandReadmethodtoretrievethed ata.Youneedtorunsomecodeoneachitem.Whatdoyouuse?A.forB.foraechC.whileD.do‐ whileCorrectAnswer:CQUESTION10Youhaveaprivatemethodinyourclassandyouwanttomakeinvoc ationofthemethodpossiblebycertaincallers.Whatdoyoudo? A.Makethemethodpublic.B.Useaneventsooutsideuserscanbenotifiedwhenthemethodisexecuted. C.Useamethodthatreturnsadelegatetoauthorizedcallers.D.Declaretheprivatemethodasalambda.C orrectAnswer:CQUESTION1Youarecreatinganewcollectiontypeandyouwanttomakesuretheeleme ntsinitcanbeeasilyaccessed.Whatshouldyouaddtothetype? A.ConstructorB.IndexerpropertyC.GenerictypeparameterD.StaticpropertyCorrectAnswer:BQUEST ION2Youarecreatingagenericclassthatshouldworkonlywithreferencetypes.Whichtypeconstraintsh ouldyouadd? A.whereT:classB.whereT:structC.whereT:new()D.whereT:IDisposableCorrectAnswer:AQUESTION3
Youpassastructvariableintoamethodasanargument.Themethodchangesthevariable;however,whe nthemethodreturns,thevariablehasnotchanged.Whathappened? A.Thevariablewasnotinitializedbeforeitwaspassedin.B.Avaluetypecannotbechangedinsideametho d.C.Passingavaluetypemakesacopyofthedata.Theoriginalwasn’tchanged.D.Themethoddidn’tretur nthechanges.CorrectAnswer:CQUESTION4YouarecreatingacustomDistanceclass.Youwanttoeaseth econversionfromyourDistanceclasstoadouble.Whatshouldyouadd? A.Nothing;thisisalreadypossible.B.Animplicitcastoperator.C.Anexplicitcastoperator.D.AstaticParse method.CorrectAnswer:BQUESTION5Youwanttodeterminewhetherthevalueofanobjectreferencei sderivedfromaparticulartype.WhichC#languagefeaturecanyouuse? (Chooseallthatapply.)A.AnasoperatorB.AnimplicitcastC.AnisoperatorD.AdynamickeywordCorrect Answer:AC QUESTION7Whataccessmodifiershouldyouusetomakesurethatamethodinaclasscanonlybeaccesse dinsidethesameassemblybyderivedtypes? A.Maketheclasspublicanditsmemberspublic.B.Maketheclasspublicanditsmembersprotected.C.Ma ketheclassinternalanditsmembersinternal.D.Maketheclassinternalanditsmembersprotected.Corr ectAnswer:DQUESTION8Youneedtoexposesomedatafromaclass.Thedatacanbereadbyothertypesb utcanbechangedonlybyderivedtypes.Whatshouldyouuse? A.AprotectedfieldB.ApublicpropertywithaprotectedsetmodifierC.AprotectedpropertyD.Aprotecte dpropertywithapublicgetmodifierCorrectAnswer:BQUESTION9Youhaveaclassthatimplementstwoi nterfacesthatbothhaveamethodwiththesamename.InterfaceIAshouldbethedefaultimplementatio n.InterfaceIBshouldbeusedonlyinspecialsituations.Howdoyouimplementthoseinterfaces? A.ImplementIAimplicitlyandIBexplicitly.B.ImplementbothIAandIBexplicitly.C.ImplementbothIAan dIBimplicitly.D.ImplementIAexplicitlyandIBimplicitly.CorrectAnswer:AQUESTION10Youwanttocrea teahierarchyoftypesbecauseyouhavesomeimplementationcodeyouwanttosharebetweenalltypes. Youalsohavesomemethodsignaturesyouwanttoshare.Whatshouldyouuse? A.AninterfaceB.Aclasswithvirtualmethods C.AnabstractclassD.AsealedclassCorrectAnswer:CQUESTION11Youwanttocreateatypethatcanbee asilysorted.Whichinterfaceshouldyouimplement? A.IEnumerableB.IComparableC.IDisposableD.IUnknownCorrectAnswer:BQUESTION12Youwanttoi nheritfromanexistingclassandaddsomebehaviortoamethod.Whichstepsdoyouhavetotake? (Chooseallthatapply.)A.Usetheabstractkeywordonthebasetype.B.Usethevirtualkeywordonthebas emethod.C.Usethenewkeywordonthederivedmethod.D.Usetheoverridekeywordonthederivedme thod.CorrectAnswer:BDQUESTION13Youwanttoreadthevalueofaprivatefieldonaclass.WhichBindi ngFlagsdoyouneed? (Chooseallthatapply.)A.InstanceB.DeclaredOnlyC.StaticD.NonPublicCorrectAnswer:AD CorrectAnswer:CQUESTION3Youaredevelopinganapplicationthatincludesthefollowingcodesegme nt. (Linenumbersareincludedforreferenceonly.)TheGetAnimals()methodmustmeetthefollowingrequi rements:ConnecttoaMicrosoftSQLServerdatabase.CreateAnimalobjectsandpopulatethemwithdat afromthedatabase.ReturnasequenceofpopulatedAnimalobjects.pan>Youneedtomeettherequire
ments.Whichtwoactionsshouldyouperform? (Eachcorrectanswerpresentspartofthesolution.Choosetwo.) A.Insertthefollowingcodesegmentatline16:while(sqlDataReader.NextResult())B.Insertthefollowin gcodesegmentatline13:sqlConnection.BeginTransaction();C.Insertthefollowingcodesegmentatline 13:sqlConnection.Open();D.Insertthefollowingcodesegmentatline16:while(sqlDataReader.Read()) E.insertthefollowingcodesegmentatline16:while(sqlDataReader.GetValues())CorrectAnswer:CDQ UESTION4DRAGDROPYouaredevelopingacustomcollectionnamedLoanCollectionforaclassnamedL oanclass.YouneedtoensurethatyoucanprocesseachLoanobjectintheLoanCollectioncollectionbyusi ngaforeachloop.Howshouldyoucompletetherelevantcode? (Toanswer,dragtheappropriatecodesegmentstothecorrectlocationsintheanswerarea.Eachcodeseg mentmaybeusedonce,morethanonce,ornotatall.Youmayneedtodragthesplitbarbetweenpanesors crolltoviewcontent.)