CramX Logo
Princeton Review AP Computer Science a Prep (College Test Preparation), 8th Edition (2023) - Document preview page 1

Princeton Review AP Computer Science a Prep (College Test Preparation), 8th Edition (2023) - Page 1

Document preview content for Princeton Review AP Computer Science a Prep (College Test Preparation), 8th Edition (2023)

Princeton Review AP Computer Science a Prep (College Test Preparation), 8th Edition (2023)

Princeton Review AP Computer Science a Prep (College Test Preparation), 8th Edition (2023) is your essential resource for acing certification exams with confidence.

Elizabeth Chen
Contributor
4.7
107
over 1 year ago
Preview (31 of 451 Pages)
100%
Log in to unlock
Page 1 of 31
Princeton Review AP Computer Science a Prep (College Test Preparation), 8th Edition (2023) - Page 1 preview image+Studyxy
Page 2 of 31
Princeton Review AP Computer Science a Prep (College Test Preparation), 8th Edition (2023) - Page 2 preview imageDownloadedfromStudyXY.comWw+StudyXYoias.Za\Rr'BE\StudyAnythingThisContentHasbeenPostedOnStudyXY.comassupplementarylearningmaterial.StudyXYdoesnotendroseanyuniversity,collegeorpublisher.Allmaterialspostedareundertheliabilityofthecontributors.|8)www.studyxy.com
Page 3 of 31
Princeton Review AP Computer Science a Prep (College Test Preparation), 8th Edition (2023) - Page 3 preview image+Studyxy
Page 4 of 31
Princeton Review AP Computer Science a Prep (College Test Preparation), 8th Edition (2023) - Page 4 preview imageThePrincetonReviewPublishingTeamRobFranek,Editor-in-ChiefDavidSoto,SeniorDirector,DataOperationsStephenKoch,SeniorManager,DataOperationsDeborahWeber,DirectorofProductionJasonUllmeyer,ProductionDesignManagerJenniferChapman,SeniorProductionArtistSelenaCoppock,DirectorofEditorialOrionMcBean,SeniorEditorAaronRiccio,SeniorEditorMeaveShelton,SeniorEditorChrisChimera,EditorPatriciaMurphy,EditorLauraRose,EditorIsabelleAppleton,EditorialAssistantPenguinRandomHousePublishingTeamTomRussell,VP,PublisherAlisonStoltzfus,SeniorDirector,PublishingBrettWright,SeniorEditorEmilyHoffman,AssistantManagingEditorEllenReed,ProductionManagerSuzanneLee,DesignerEugeniaLo,PublishingAssistantThePrincetonReview110East42ndSt,7thFloorNewYork,NY10017Copyright©2023byTPREducationIPHoldings,LLC.AllrightsreservedPublishedintheUnitedStatesbyPenguinRandomHouseLLC,NewYork.TermsofService:ThePrincetonReviewOnlineCompanionTools(“StudentTools’)forretailbooksareavailableforonlythetwomostrecenteditionsofthatbook.StudentToolsmaybeactivatedonlyoncepereligiblebookpurchasedforatotalof24monthsofaccess.ActivationofStudentToolsmorethanonceperbookisindirectviolationoftheseTermsofServiceandmayresultindiscontinuationofaccesstoStudentToolsServices.Thematerialinthisbookisup-to-dateatthetimeofpublication.However,changesmayhavebeeninstitutedbythetestingbodyinthetestafterthisbookwaspublished.Ifthereareanyimportantlate-breakingdevelopments,changes,orcorrectionstothematerialsinthisbook,wewillpostthatinformationonlineintheStudentTools.RegisteryourbookandcheckyourStudentToolstoseeifthereareanyupdatespostedthereISBN9780593517055EbookISBN9780593517062APisatrademarkregisteredandownedbytheCollegeBoard,whichisnotaffiliatedwith,anddoesnotendorse,thisproduct.ThePrincetonReviewisnotaffiliatedwithPrincetonUniversity.Editor:ChrisChimeraProductionEditors:AliLandreau,SarahLittProductionArtist:JenniferChapmanContentDeveloper:AnnHeltzelCoverartbyKonstantinInozemtsev/AlamyStockPhotoCoverdesignbySuzanneLeePhotoselectionandlayoutbyCarlingDesign,Inc.|vv1StudyXY
Page 5 of 31
Princeton Review AP Computer Science a Prep (College Test Preparation), 8th Edition (2023) - Page 5 preview imageForcustomerservice,pleasecontacteditorialsupport@review.com,andbesuretoinclude:«fulltitleofthebook+ISBN+pagenumbera_prh_6.0_144897283_c0_r0|ve—~StudyXY
Page 6 of 31
Princeton Review AP Computer Science a Prep (College Test Preparation), 8th Edition (2023) - Page 6 preview imageAcknowledgmentsSpecialthankstoAnnHeltzelforhersuperbcontentdevelopmentworkonthe8theditionofthisbook.Additionally,ThePrincetonReviewwouldliketothankJenniferChapman,AliLandreau,andSarahLittfortheircontributionstothistitle.+StudyXy
Page 7 of 31
Princeton Review AP Computer Science a Prep (College Test Preparation), 8th Edition (2023) - Page 7 preview imageContentsGetMore(Free)ContentPartI:UsingThisBooktoImproveYourAPScorePreview:YourKnowledge,YourExpectationsYourGuidetoUsingThisBookHowtoBeginPartII:PracticeTest1PracticeTest1PracticeTest1:DiagnosticAnswerKeyandExplanationsHowtoScorePracticeTest1Partlll:AbouttheAPComputerScienceAExamTheStructureoftheAPComputerScienceAExamHowAPExamsAreUsedOtherResourcesHaveYouHeardAboutAPComputerSciencePrinciples?InConclusionPartIV:Test-TakingStrategiesfortheAPComputerScienceAExamPreview1HowtoApproachMultiple-ChoiceQuestions2HowtoApproachFree-ResponseQuestionsReflectPartV:ContentReviewfortheAPComputerScienceAExam3PrimitiveTypesProgrammingStyleComments,Identifiers,WhiteSpaceCompiling&ErrorsObjects&PrimitiveDataOutput(andSomeInput)Variables&AssignmentTheFourDataTypes—int,double,boolean,char
Page 8 of 31
Princeton Review AP Computer Science a Prep (College Test Preparation), 8th Edition (2023) - Page 8 preview imageArithmeticOperationsKeyTermsChapter3ReviewDrillSummary4UsingClassesandObjectsTheMathClassTheStringClassKeyTermsChapter4ReviewDrillSummary5BooleanExpressionsandi£StatementsTheifStatementKeyTermsChapter5ReviewDrillSummary6IterationThewhileStatementTheforStatementKeyTermsChapter6ReviewDrillSummary7WritingClassesDesign&StructureMethodsCompositionReferencesStaticModifierKeyTermsChapter7ReviewDrillSummary8ArrayPrimitives&ObjectsSearchesSortsImplementationofaSelectionSortImplementationofanInsertionSortImplementationofaMergeSort
Page 9 of 31
Princeton Review AP Computer Science a Prep (College Test Preparation), 8th Edition (2023) - Page 9 preview imageKeyTermsChapter8ReviewDrillSummary9ArrayListLists&ArrayListsArraysversusArrayListChartKeyTermsChapter9ReviewDrillSummary102DArrays2DArraysKeyTermsChapter10ReviewDrillSummary11InheritanceHierarchies&DesignPolymorphismKeyTermsChapter11ReviewDrillSummary12RecursionRecursionRecursivelyTraversingArraysKeyTermsChapter12ReviewDrillSummary13ChapterReviewDrillAnswersandExplanations14RequiredLabTimeandSuggestedLabsPartVI:PracticeTestsPracticeTest2PracticeTest2:AnswersandExplanationsHowtoScorePracticeTest2PracticeTest3PracticeTest3:AnswersandExplanationsHowtoScorePracticeTest3
Page 10 of 31
Princeton Review AP Computer Science a Prep (College Test Preparation), 8th Edition (2023) - Page 10 preview imageOnlinePracticeTestsGlossary+StudyXy
Page 11 of 31
Princeton Review AP Computer Science a Prep (College Test Preparation), 8th Edition (2023) - Page 11 preview imageOnlinePracticeTestsClickheretogototheonlinesupplementforthisbook.«PracticeTest4«PracticeTest4:AnswersandExplanations«PracticeTest5«PracticeTest5:AnswersandExplanations+StudyXy
Page 12 of 31
Princeton Review AP Computer Science a Prep (College Test Preparation), 8th Edition (2023) - Page 12 preview image1GotoPrincetonReview.com/prepandenterthefollowingISBNforyourbook:97805935170622AnswerafewsimplequestionstosetupanexclusivePrincetonReviewaccount.(Ifyoualreadyhaveone,youcanjustlogin.)3EnjoyaccesstoyourFREEcontent!Needtoreportapotentialcontentissue?ContactEditorialSupport@review.comandinclude:«fulltitleofthebook«ISBN«pagenumberNeedtoreportatechnicalissue?ContactTPRStudentTech@review.comandprovide:«yourfullname«emailaddressusedtoregisterthebook«fullbooktitleandISBN«Operatingsystem(Mac/PC)andbrowser(Chrome,Firefox,Safari,etc.)Onceyou’veregistered,youcan...«Takeafull-lengthpracticeSATandACT«AccessPracticeTests4and5plusdetailedAnswersandExplanations«Getvaluableadviceaboutthecollegeapplicationprocess,includingtipsforwritingagreatessayandwheretoapplyforfinancialaid«Ifyou'restillchoosingbetweencolleges,useoursearchablerankingsofTheBest389Collegestofindoutmoreinformationaboutyourdreamschool«AccesscomprehensivestudyguidesandavarietyofprintableresourcesincludingAPScoreConversioncharts,KeyTermslists,andtheGlossary«Checktoseeiftherehavebeenanycorrectionsorupdatestothisedition+StudyXy
Page 13 of 31
Princeton Review AP Computer Science a Prep (College Test Preparation), 8th Edition (2023) - Page 13 preview image«GetourtakeonanyrecentorpendingupdatestotheAPComputerScienceAExamLookForTheseIconsThroughoutTheBookPROVENTECHNIQUESAPPLIEDSTRATEGIESSTUDYBREAKOTHERREFERENCESONLINEARTICLESONLINEVIDEOTUTORIALS
Page 14 of 31
Princeton Review AP Computer Science a Prep (College Test Preparation), 8th Edition (2023) - Page 14 preview image+Studyxy
Page 15 of 31
Princeton Review AP Computer Science a Prep (College Test Preparation), 8th Edition (2023) - Page 15 preview imagePartIUsingThisBooktoImproveYourAPScore+Preview:YourKnowledge,YourExpectations+YourGuidetoUsingThisBook+HowtoBegin
Page 16 of 31
Princeton Review AP Computer Science a Prep (College Test Preparation), 8th Edition (2023) - Page 16 preview imagePREVIEW:YOURKNOWLEDGE,YOUREXPECTATIONSYourroutetoahighscoreontheAPComputerScienceAExamdependsalotonhowyouplantousethisbook.Startthinkingaboutyourplanbyrespondingtothefollowingquestions.1.RateyourlevelofconfidenceinyourknowledgeofthecontenttestedbytheAPComputerScienceAExam:A.Veryconfident—Iknowitall.B.I'mprettyconfident,buttherearetopicswithwhichIcouldusehelp.C.Notconfident—Ineedquiteabitofsupport.D.I’mnotsure.2.Ifyouhaveagoalscoreinmind,chooseitfortheAPComputerScienceAExam:54321I’mnotsureyet.3.Whatdoyouexpecttolearnfromthisbook?Chooseallthatapplytoyou.A.AgeneraloverviewofthetestandwhattoexpectB.StrategiesforhowtoapproachthetestC.ThecontenttestedbythisexamD.I'mnotsureyet.YOURGUIDETOUSINGTHISBOOKThisbookisorganizedtoprovideasmuch—oraslittle—supportasyouneed,soyoucanusethisbookinwhateverwaywillbemosthelpfultoimprovingyourscoreontheAPComputerScienceAExam.«TheremainderofPartIwillprovideguidanceonhowtousethisbookandhelpyoudetermineyourstrengthsandweaknesses.«PartIIofthisbookcontainsyourfirstpracticetest,aDiagnosticAnswerKey,detailedanswersandexplanationsforeachquestion,andascoringguide.Werecommendthatyoutakethistestbeforegoinganyfurtherinordertorealisticallydetermine:©yourstartingpointrightnow°whichquestiontypesyou’rereadyforandwhichyoumightneedtopractice°whichcontenttopicsyouarefamiliarwithandwhichyoushouldreviewcarefully+StudyXy
Page 17 of 31
Princeton Review AP Computer Science a Prep (College Test Preparation), 8th Edition (2023) - Page 17 preview imageIt'sBubbleTimeBubblesheetsforthetestsinthisbookcanbefoundonline—youcanprintthemfromyouronlinestudenttools.Wehighlyrecommendthatyoudosobeforetakingapracticetest,aslearninghowtotransferyouranswerstoabubblesheetisanimportantpartofpreparingforthetest.Onceyouhavenaileddownyourstrengthsandweaknesseswithregardtothisexam,youcanfocusyourtestpreparation,buildastudyplan,andbeefficientwithyourtime.OurDiagnosticAnswerKeywillassistyouwiththisprocess.«PartIIIofthisbookwill:°provideinformationaboutthestructure,scoring,andcontentoftheAPComputerScienceAExam©helpyoutomakeastudyplan©pointyoutowardadditionalresources«PartIVofthisbookwillexplorevariousstrategies,including:>howtoattackmultiple-choicequestions>howtoeffectivelyanswerfree-responsequestions>howtomanageyourtimetomaximizethenumberofpointsavailabletoyou«PartVofthisbookcoversthecontentyouneedtoknowfortheAPComputerScienceAExam.«PartVIofthisbookcontainsPracticeTests2and3,plustheiranswersandexplanations,andascoringguide.(PracticeTests4and5andtheiranswersandexplanationscanbefoundonline.)WerecommendthatyoupepperinPracticeTestsasyoustudyforyourexam.Don’ttakeallthePracticeTestsinaroworeveninrapidsuccession:startwithPracticeTest1togetasenseofwhereyouare.Then,asyoucompleteyourcontentreview,takeaPracticeTesteverysooftentoseehowyouaredoingandwhetheryouareimprovingorneedtoreviewcertaintopics.Youmaychoosetousesomepartsofthisbookoverothers,oryoumayworkthroughtheentirebook.Yourapproachwilldependonyourneedsandhowmuchtimeyouhave.Now,let’slookathowtomakethisdetermination.1.TakePracticeTest1Beforeyoucandecidehowtousethisbook,youneedtotakeapracticetest.Doingsowillgiveyouinsightintoyourstrengthsandweaknesses,andtheirStudyXy
Page 18 of 31
Princeton Review AP Computer Science a Prep (College Test Preparation), 8th Edition (2023) - Page 18 preview imagetestwillalsohelpyoumakeaneffectivestudyplan.Ifyou'refeelingtest-phobic,remindyourselfthatapracticetestisatoolfordiagnosingyourself—it’snothowwellyoudothatmattersbuthowyouuseinformationgleanedfromyourperformancetoguideyourpreparation.So,beforeyoureadfurther,takePracticeTest1startingonthispageofthisbook.Besuretofinishitinonesitting,followingtheinstructionsthatappearbeforethetest.2.CheckYourAnswersUsingtheDiagnosticAnswerKeyonthispage,followourthree-stepprocesstoidentifyyourstrengthsandweaknesseswithregardtothetestedtopics.Thiswillhelpyoudeterminewhichcontentreviewchapterstoprioritizewhenstudyingthisbook.Don’tworryabouttheexplanationsfornow,anddon’tworryaboutmissedquestions.We'llgettothatsoon.BonusTipsandTricks...CheckusoutonYouTubefortest-takingtipsandtrickstohelpyouaceyournextexamatwww.youtube.com/ThePrincetonReview3.ReflectontheTestAfteryoutakeyourfirsttest,respondtothefollowingquestions:+Howmuchtimedidyouspendonthemultiple-choicequestions?+Howmuchtimedidyouspendoneachfree-responsequestion?+Howmanymultiple-choicequestionsdidyouanswercorrectlyandhowmanydidyoumiss?«Doyoufeelyouhadtheknowledgetoaddressthesubjectmatterofthefree-responsequestions?4.ReadPartIIIofthisBookandCompletetheSelf-EvaluationPartIIIwillprovideinformationonhowthetestisstructuredandscored.Itwillalsosetoutareasofcontentthataretested.AsyoureadPartIII,re-evaluateyouranswerstothequestionsabove.AttheendofPartIII,youwillrevisitandrefinethosequestions.Youwillthenbeabletomakeastudyplan,basedonyourneedsandavailabletime,thatwillallowyoutousethisbookmosteffectively.5.EngagewithPartsIVandVasNeeded+StudyXY
Page 19 of 31
Princeton Review AP Computer Science a Prep (College Test Preparation), 8th Edition (2023) - Page 19 preview imageNoticethewordengage.You'llgetmoreoutofthisbookifyouuseitintentionallythanifyoureaditpassively,hopingforanimprovedscorethroughosmosis.Thestrategychapterswillhelpyouthinkaboutyourapproachtothequestiontypesonthisexam.PartIVwillopenwitharemindertothinkabouthowyouapproachquestionsnowandthenclosewithareflectionsectionaskingyoutothinkabouthoworwhetheryouwillchangeyourapproachinthefuture.ThecontentchaptersinPartVaredesignedtoprovideareviewofthecontenttestedontheAPComputerScienceAExam,includingthelevelofdetailyouneedtoknowandhowthecontentistested.Inaddition,thecontentchaptersarebrokenuptoexactlymatchthe10-unitstructureoftheAPComputerScienceAcourse,asoutlinedbytheCollegeBoard.Youwillhavetheopportunitytoassessyourproficiencyinthecontentofeachchapterthroughtest-appropriatequestionsandareflectionsection.6.TakePracticeTests2,3,4,and5andAssessYourPerformanceOnceyoufeelyouhavedevelopedthestrategiesyouneedandgainedtheknowledgeyoulacked,youshouldtakePracticeTest2,whichstartsonthispageofthisbook.Youshoulddosoinonesitting,followingtheinstructionsatthebeginningofthetest.‘Whenyouarefinished,checkyouranswerstothemultiple-choicesections.Seewhetherateacherorfriendwillreadyourfree-responseanswers,providefeedback,andgooverthemwithyou.Onceyouhavetakenthetest,reflectontheareasonwhichyoustillneedwork,andrevisitthechaptersinthisbookthataddressthosedeficiencies.ThengobackandtakePracticeTest3anddothesame,thenPracticeTest4,thenPracticeTest5.Youhave5practicetestswiththisbook—Dbesuretomakeuseofallofthem!(NotethatPracticeTests4and5areonlinePDFsfoundinyourStudentTools.Gobackafewpagesforstep-by-stepdirectionsonhowtoregisteryourbookandaccessallofyouronlineresources.)NeedSomeGuidance?Ifyou'relookingforawaytogetthemostoutofyourstudying,checkoutourfreestudyguideforthisexam,whichyoucanaccessviayouronlinestudenttools.Seethe“GetMore(Free)Content”pagefordetailsonaccessingthisgreatresourceandmore.7.KeepWorking+StudyXy
Page 20 of 31
Princeton Review AP Computer Science a Prep (College Test Preparation), 8th Edition (2023) - Page 20 preview imageAsmentionedearlier,thereareotherresourcesavailabletoyou,includingawealthofinformationontheAPStudentswebsiteapstudent.collegeboard.org/apcourse/ap-computer-science-a).Onthissite,youcancontinuetoexploreareasthatyoucouldimproveuponandengageinthoseareasrightupuntilthedayofthetest.Youshoulduseamixofwebresourcesandbookreviewtosolidifyyourunderstandingofanyquestionsubjectsthatyoukeepgettingwrong.
Page 21 of 31
Princeton Review AP Computer Science a Prep (College Test Preparation), 8th Edition (2023) - Page 21 preview imagePartIIPracticeTest1+PracticeTest1+PracticeTest1:DiagnosticAnswerKeyandExplanations+HowtoScorePracticeTest1
Page 22 of 31
Princeton Review AP Computer Science a Prep (College Test Preparation), 8th Edition (2023) - Page 22 preview imagePracticeTest1ClickheretodownloadaPDFofPracticeTest1.
Page 23 of 31
Princeton Review AP Computer Science a Prep (College Test Preparation), 8th Edition (2023) - Page 23 preview imageTheExamAP®ComputerScienceAExamSECTIONI:Multiple-ChoiceQuestionsDONOTOPENTHISBOOKLETUNTILYOUARETOLDTODOSO.AtaGlanceTotalTime1hour30minutesNumberofQuestions40PercentofTotalScore50%WritingInstrumentPencilrequiredInstructionsSectionIofthisexaminationcontains40multiple-choicequestions.Fillinonlytheovalsfornumbers1through40onyouranswersheet.Indicateallofyouranswerstothemultiple-choicequestionsontheanswersheet.Nocreditwillbegivenforanythingwritteninthisexambooklet,butyoumayusethebookletfornotesorscratchwork.Afteryouhavedecidedwhichofthesuggestedanswersisbest,completelyfillinthecorrespondingovalontheanswersheet.Giveonlyoneanswertoeachquestion.Ifyouchangeananswer,besurethatthepreviousmarkiserasedcompletely.Hereisasamplequestionandanswer.SampleQuestionChicagoisa(A)state(B)city(C)country(D)continent(E)countySampleAnswer+Studyxy
Page 24 of 31
Princeton Review AP Computer Science a Prep (College Test Preparation), 8th Edition (2023) - Page 24 preview imageUseyourtimeeffectively,workingasquicklyasyoucanwithoutlosingaccuracy.Donotspendtoomuchtimeonanyonequestion.Goontootherquestionsandcomebacktotheonesyouhavenotansweredifyouhavetime.Itisnotexpectedthateveryonewillknowtheanswerstoallthemultiple-choicequestions.AboutGuessingManycandidateswonderwhetherornottoguesstheanswerstoquestionsaboutwhichtheyarenotcertain.Multiple-choicescoresarebasedonthenumberofquestionsansweredcorrectly.Pointsarenotdeductedforincorrectanswers,andnopointsareawardedforunansweredquestions.Becausepointsarenotdeductedforincorrectanswers,youareencouragedtoanswerallmultiple-choicequestions.Onanyquestionsyoudonotknowtheanswerto,youshouldeliminateasmanychoicesasyoucan,andthenselectthebestansweramongtheremainingchoices.+StudyXy
Page 25 of 31
Princeton Review AP Computer Science a Prep (College Test Preparation), 8th Edition (2023) - Page 25 preview imageJavaQuickReferenceClassConstructorsand|ExplanationMethodsStringClassString(StringConstructsanewStringobjectthatrepresentsthestr)samesequenceofcharactersasstrintlength()ReturnsthenumberofcharactersinaStringobjectStringReturnsthesubstringbeginningatindexfromandsubstring(intendingatindexto1from,intto)StringReturnssubstring(from,length()substring(intfrom)intReturnstheindexofthefirstoccurrenceofstr;indexOf(Stringreturns—1ifnotfoundstr)booleanReturnstrueifthisisequaltoother;returnsequals(Stringfalseotherwiseother)intReturnsavalue<0ifthisislessthanother;compareTo(String|returnszeroifthisisequaltoother;returnsaother)value>0ifthisisgreaterthanotherIntegerClassInteger(intConstructsanewIntegerobjectthatrepresentsthevalue)specifiedintvalueInteger.MIN_VALUE|TheminimumvaluerepresentedbyanintorIntegerInteger.MAXVALUE|ThemaximumvaluerepresentedbyanintorIntegerintintvalue()ReturnsthevalueofthisIntegerasanintDoubleClassDouble(doubleConstructsanewDoubleobjectthatrepresentsthevalue)specifieddoublevaluedoubleReturnsthevalueofthisDoubleasadoubledoubleValue()+StudyXY
Page 26 of 31
Princeton Review AP Computer Science a Prep (College Test Preparation), 8th Edition (2023) - Page 26 preview imageMathClassstaticintReturnstheabsolutevalueofanintvalueabs(intx)staticdoubleReturnstheabsolutevalueofadoublevalueabs(doublex)staticdoubleReturnsthevalueofthefirstparameterraisedtothepow(doublebase,|powerofthesecondparameterdoubleexponent)staticdoubleReturnsthepositivesquarerootofadoublevaluesqrt(doublex)staticdoubleReturnsadoublevaluegreaterthanorequalto0.0random()andlessthan1.0ArrayListClassReturnsthenumberofelementsinthelistbooleanadd(EAppendsobjtoendoflist;returnstrueobj)voidadd(intInsertsobjatpositionindex(0<=index<=index,Eobj)size),movingelementsatpositionindexandhighertotheright(adds1totheirindices)andadds1tosizeEget(intindex)|ReturnstheelementatpositionindexinthelistEset(intindex,[Replacestheelementatpositionindexwithobj;Eobj)returnstheelementformerlyatpositionindexEremove(intRemoveselementfrompositionindex,movingindex)elementsatpositionindex+1andhighertotheleft(subtracts1fromtheirindices)andsubtracts1fromsize;returnstheelementformerlyatpositionindexObjectClassbooleanequals(Objectother)StringtoString()+StudyXY
Page 27 of 31
Princeton Review AP Computer Science a Prep (College Test Preparation), 8th Edition (2023) - Page 27 preview imageCOMPUTERSCIENCEASECTIONITime—1hourand30minutesNumberofQuestions—40Percentoftotalexamgrade—50%Directions:Determinetheanswertoeachofthefollowingquestionsorincompletestatements,usingtheavailablespaceforanynecessaryscratchwork.Thendecidewhichisthebestofthechoicesgivenandfillinthecorrespondingovalontheanswersheet.Nocreditwillbegivenforanythingwrittenintheexaminationbooklet.Donotspendtoomuchtimeonanyoneproblem.Notes:«AssumethattheclasseslistedintheQuickReferencehavebeenimportedwhereappropriate.+Assumethatdeclarationsofvariablesandmethodsappearwithinthecontextofanenclosingclass.+Assumethatmethodcallsthatarenotprefixedwithanobjectorclassnameandarenotshownwithinacompleteclassdefinitionappearwithinthecontextofanenclosingclass.+Unlessotherwisenotedinthequestion,assumethatparametersinthemethodcallsarenotnullandthatmethodsarecalledonlywhentheirpreconditionsaresatisfied.1.Evaluatethefollowingexpression:4+6%12/4A)1(B)2©)4(D)4.5(E)52.WhichofthefollowingexpressionsdoesNOTevaluateto0.2?(A)(1.0*2)/(1.0*10)B)2.0/10(C)(double)2/10(D)(double)(2/10)(E)Math.sqrt(4)/Math.sqrt(100)3.Choosethecodeusedtoprintthefollowing:+StudyXY
Page 28 of 31
Princeton Review AP Computer Science a Prep (College Test Preparation), 8th Edition (2023) - Page 28 preview image“Friends”(A)System.out.print(“WFriends””);(B)Ssystem.out.print(“//“Friends//"");(C)system.out.print(“/“Friends/””);(D)System.out.print("\“Friends\””);(E)system.out.print("\\“Friends\\"”);4.Determinetheoutputofthefollowingcode.Stringanimall=“elephant”;Stringanimal2=“lion”;swap(animall,animal2);animall.toUpperCase();animal?2.toLowerCase();System.out.println(animall++animal?);publicstaticvoidswap(Stringal,Stringa2){Stringhold=al;al=a2;a2=hold;}(A)elephantlion(B)ELEPHANTlion(C)lionelephant(D)LIONelephant(E)LIONELEPHANTQuestions5-6refertotheConstellationclassbelow.publicclassConstellationprivateStringname;privateStringmonth;privateintnorthernLatitude;privateintsouthernLatitude;Constellation(Stringn,Stringm){name=n;month=m;northernLatitude=0;southernLatitude=0;+StudyXY
Page 29 of 31
Princeton Review AP Computer Science a Prep (College Test Preparation), 8th Edition (2023) - Page 29 preview image}Constellation(Stringn,Stringm,intnLat,intsLat){name=n;month=m;northernLatitude=nLat;southernlLatitude=slat;}publicvoidchgMonth(Stringm){Stringmonth=m;}5.UsingtheConstellationclass,whichofthefollowingwillcauseacompilererror?(A)Constellationcl=newConstellation(“Hercules”,July”);(B)Constellationc2=newConstellation(“Pisces”,“Nov”,90,65);(C)Constellationc3=newConstellation(“Aquarius”,“Oct”,65.0,90.0);(D)Constellationc4=newConstellation(“Leo”,“4”,0,0);(E)Constellationc¢5=newConstellation(“Phoenix”,“Nov”,32,90);6.AprogrammerhasattemptedtoaddthreemutatormethodstotheConstellationclass.I.publicvoidchgLatitude(Stringdirection,intlatitude){if(direction.toUpperCase().equals(“N”))northernLatitude=latitude;elseif(direction.toUpperCase().equals(“S”))southernLatitude=latitude;}II.publicvoidchglatitude(intnLatitude,intsLatitude){
Page 30 of 31
Princeton Review AP Computer Science a Prep (College Test Preparation), 8th Edition (2023) - Page 30 preview imagenorthernLatitude=nLatitude;southernlLatitude=sLatitude;}III.publicvoidchglatitude(doublenLatitude,doublesLatitude){northernLatitude=(int)nLatitude;southernLatitude=(int)sLatitude;}Whichofthethreewillcompilewithoutacompilererror?(A)Ionly(B)ITonly(C)IIIonly(D)IandIIonly(E)I11,andIIT7.Determinethevaluesofxandyafterthefollowingcoderuns.intx=10;inty=5;if(x==10){if(y<=5)y+;elseif(y<4)x=3;elsey+=6;}if(y>5){if(x!=10){x=0;y=0;}elsex==5;}A)x=0,y=0
Page 31 of 31
Princeton Review AP Computer Science a Prep (College Test Preparation), 8th Edition (2023) - Page 31 preview imageB)x=-5,y=6©)x=10,y=5Myx=3,y=5(E)Noneoftheabove8.Aprogrammerintendedtowritecodetoprintthreewordsinascendinglexicographicalorder.Followthecodeanddeterminetheprintedoutput.1Stringwordl=“frog”;2Stringword2=“dog”;3Stringword3=“cat”;45if(wordl.compareTo(word2)<0)6if(word2.compareTo(word3)<0)7System.out.println(wordl++word2++word3);8else9System.out.println(wordl++word3++word2);10else11if(wordl.compareTo(word2)>0)12if(word2.compareTo(word3)<0)13System.out.println(wordl++word2++word3);14else15System.out.println(wordl++word3++word2);16else17if(word2.equals(word3))18System.out.println(“allthewordsarethesame”);19else20System.out.println(“wordlandword2areduplicates”);(A)frogcatdog(B)catdogfrog(C)dogfrogcat(D)frogdogcat(E)dogcatfrog9.Usingthefollowingvariabledeclarations,determinewhichofthefollowingwouldevaluatetotrue.
Preview Mode

This document has 451 pages. Sign in to access the full document!

Princeton Review AP Computer Science a Prep (College Test Preparation), 8th Edition (2023) - Certification Guides | Advanced Placement