[PDF] [PDF] AP Computer Science A, 7th Edition - Moore Public Schools

AP Computer Science Levels A and AB, 2003 under the title cluded in the book because they are useful in the free-response questions Sections in



Previous PDF Next PDF





[PDF] AP Computer Science A 2016 Free-Response Questions

2016 AP® COMPUTER SCIENCE A FREE-RESPONSE QUESTIONS This question involves the implementation and extension of a RandomStringChooser  



[PDF] AP Computer Science A Exam Scoring Guidelines, 2016

A maximum of 3 penalty points may be assessed per question 1-Point Penalty v) Array/collection access confusion ([] get) w) Extraneous code that causes side- 



[PDF] Be Prepared for the AP Computer Science Exam in Java - Skylight

for the AP Computer Science Exam in Java Chapter 6: Annotated Solutions to Past Free-Response Questions 2016 Maria Litvin Phillips Academy, Andover 



[PDF] AP Computer Science (A) Course Syllabus 2015-2016 Curricular

Schram, Leon Multiple-Choice Free-Response Questions in Preparation for the AP Computer Science Examination 9th Ed New York: D&S Marketing, 2015



[PDF] AP Computer Science A, 7th Edition - Moore Public Schools

AP Computer Science Levels A and AB, 2003 under the title cluded in the book because they are useful in the free-response questions Sections in



[PDF] Flash Cards

AP Computer Science * Mrs Dovi * Patrick Henry High School * Ashland VA Integer For these problems [ay special at- If this is a free response question



[PDF] OCR AS Level Computer Science H046 Specification,

The quality of extended responses are assessed in the written papers where indicated by an asterisk Page 12 © OCR 2016 AS Level in Computer Science 6



[PDF] Computer Science Answers Chapter 1 – Problem Solving - Edexcel

Pearson Education Ltd 2016 This material is not copyright free their version so that entry of any other letter gets an 'invalid entry' response one of the players reaches a score of 30 or more or the computer runs out of questions stop the



[PDF] Which Computer Science Class should I take? Exploring Computer

Exploring Computer Science is for students with little or no previous knowledge of programming AP Computer Science Principles is for students who have completed an introductory course, but are not yet ready for problems without seeking immediate assistance or getting frustrated Multiple-choice and free- response

[PDF] ap computer science a 2016 scoring guidelines

[PDF] ap computer science a 2018 multiple choice

[PDF] ap computer science a 2018 scoring guidelines

[PDF] ap computer science a 2019 free response answers

[PDF] ap computer science a 2019 frq scoring guidelines

[PDF] ap computer science a 2019 scoring guidelines

[PDF] ap computer science a archive

[PDF] ap computer science a consumer review lab answers

[PDF] ap computer science a data lab

[PDF] ap computer science a exam 2018

[PDF] ap computer science a exam 2019

[PDF] ap computer science a exam 2020 answers

[PDF] ap computer science a exam 2020 cheat sheet

[PDF] ap computer science a exam 2020 date

[PDF] ap computer science a exam 2020 format

MOST UP-TO-DATE REVIEW

AND PRACTICE TESTS

CURRENTLY AVAILABLE

7TH EDITION

Roselyn Teukolsky, M.S.

4 full-length practice tests with explained

answers, including one online

Expert advice on the best way to appr oach

the test

Review covers all relevant topics, including the

new AP Computer Science A labs and changes to the Java subset

BARRON'S

The Leader in Test Preparation

*AP and Advanced Placement Program are registered trademarks of the College Boar d, which was not involved in the production of, and does not endorse, this product. with BARRON'S

SCORE HIGHER

ISBN: 978-1-4380-0594-2

EAN $18.99 Canada $21.99 www.barronseduc.com

PRINTED

IN THE

USA

BARRON'S

Teukolsky

AP

COMPUTERSCIENCE A

APSTUDYGREEN.

STUDY

GREEN.

STUDY

GREEN.

STUDYGREEN.

S T U D Y G R E E N

Printed on partially recycled paper

Fully recyclable

COMPUTER SCIENCE A

BARRON'S GIVES YOU THE ANSWERS!

Every question in this book comes with a comprehensive answer explanatio n.

New chapter on

the Computer

Science A labs

7TH EDITION

Everything you need

to get a 5 5

For 70 years,

BARRON'S

experts have been helping students surpass their expectations on standardized tests. This is the only book you will need to get the score you want on the AP Computer

Science A test.

Proven test-taking strategies that make the difference between a good score and a great score One full-length diagnostic test to help you pinpoint your strengths and weaknesses Two additional full-length practice tests to boost your condence The most up-to-date subject review that covers the specic material you need to know for the test

Access to a full-length sample AP Computer Science A exam with answer explanations and automatic scoring

See inside front cover for details.

4-0594-AP-ComputerScienceA-fbs.indd All Pages11/7/14 12:41 PM

4-0594-AP-ComputerScienceA-IFC.indd All Pages11/5/14 12:54 PM

Roselyn Teukolsky, M.S.

Formerly, Ithaca High School

Ithaca, New York

BARRON'S

*AP and Advanced Placement Program are registered trademarks of the College Board, which was not involved in the production of, and does not endorse, this book.

7TH EDITION

COMPUTER

SCIENCE A

AP

4-0594-APComputerScienceA-tp.indd 110/7/14 9:09 AM

i i “ap" — 2014/11/4— 11:10 — page ii — #2i i i i i i

About the Author:

Roselyn Teukolsky has an M.S. degree from Cornell University, and has been teaching programming and com-

puter science since 1980. She has published articles inThe Mathematics Teacherand in the National Council

of Teachers of Mathematics Yearbook. She is the author of Barron'sACT Math and Science Workbookand co-

author of Barron'sSAT 2400: Aiming for the Perfect Score.She has received the Edyth May Sliffe Award for

Distinguished Mathematics Teaching and the Alfred Kalfus Distinguished Coach Award from the New York

State Math League (NYSML).

c Copyright 2015, 2013, 2010 by Barron's Educational Series, Inc.

Previous editionsc

copyright 2007 under the title AP Computer Science Levels A and AB, 2003 under the title How to Prepare for the AP Computer Science Advanced

Placement Examination, JAVA Version, and 2001

under the titleHow to Prepare for the AP Computer

Science Advanced Placement Examination

by Barron's Educational Series, Inc.

All rights reserved.

No part of this publication may be reproduced or

distributed in any form or by any means without the written permission of the copyright owner.

All inquiries should be addressed to:

Barron's Educational Series, Inc.

250 Wireless Boulevard

Hauppauge, New York 11788

www.barronseduc.com

ISBN: 978-1-4380-0594-2

ISBN (with CD-ROM): 978-1-4380-7553-2

ISSN (Print): 2169-5571

ISSN (Print with CD-ROM): 2169-558X

PRINTED IN THE UNITED STATES OF AMERICA

9 8 7 6 5 4 3 2 1

i i “ap" — 2014/11/4— 11:10 — page iii — #3i i i i i i

Contents

Prefaceix

Introductionxi

General Information About the Exam . . . . . . . . . . . . . . . . . . . . . . . xi Hints for Taking the Exam . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xii The Multiple-Choice Section . . . . . . . . . . . . . . . . . . . . . . . . . . . . xii The Free-Response Section. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xii How to Use This Book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii

Practice Exam One / Diagnostic Test1

Computer Science Section I . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Computer Science Section II . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 Answer Key (Section I) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 Diagnostic Chart for Practice Exam . . . . . . . . . . . . . . . . . . . . . . . . . 45 Answers Explained . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47

Chapter 1. Introductory Java Language Features57

Packages and Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 Javadoc Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 Types and Identiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 Identiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 Built-in Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 Storage of Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 Hexadecimal and Octal Numbers . . . . . . . . . . . . . . . . . . . . . . . . . 62 Final Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 Arithmetic Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 Relational Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 Logical Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 Assignment Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 Increment and Decrement Operators . . . . . . . . . . . . . . . . . . . . . . . 66 Operator Precedence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 Input/Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 Escape Sequences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 Control Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 Decision-Making Control Structures . . . . . . . . . . . . . . . . . . . . . . . 69 Iteration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 Errors and Exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 Multiple-Choice Questions on Introductory Java Language Concepts . . 77 Answer Key . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 Answers Explained . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 iii i i “ap" — 2014/11/4— 11:10 — page iv — #4i i i i i i ivContents

Chapter 2. Classes and Objects92

Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92 Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 Public, Private, and Static . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 Headers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 Types of Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 Method Overloading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 Scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 ThethisKeyword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 Reference vs. Primitive Data Types . . . . . . . . . . . . . . . . . . . . . . . . 101 The Null Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 Method Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 Multiple-Choice Questions on Classes and Objects . . . . . . . . . . . . . . . 111 Answer Key . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126 Answers Explained . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126

Chapter 3. Inheritance and Polymorphism131

Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131 Superclass and Subclass . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131 Inheritance Hierarchy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131 Implementing Subclasses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132 Declaring Subclass Objects. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137 Polymorphism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 Dynamic Binding (Late Binding) . . . . . . . . . . . . . . . . . . . . . . . . . . 138 Usingsuperin a Subclass . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 Type Compatibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 Downcasting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 TheClassCastException. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142 Abstract Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142 Abstract Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142 TheabstractKeyword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142 Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144 Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144 Dening an Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145 TheimplementsKeyword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145 TheComparableInterface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145 Multiple-Choice Questions on Inheritance and Polymorphism . . . . . . . 150 Answer Key . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169 Answers Explained . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169

Chapter 4. Some Standard Classes174

TheObjectClass . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174 The Universal Superclass . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174 Methods inObject. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174 TheStringClass . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177 StringObjects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177 ConstructingStringObjects . . . . . . . . . . . . . . . . . . . . . . . . . . . 177 The Concatenation Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178 i i “ap" — 2014/11/4— 11:10 — page v — #5i i i i i i

Contentsv

Comparison ofStringObjects . . . . . . . . . . . . . . . . . . . . . . . . . . 178 OtherStringMethods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179 Wrapper Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180 TheIntegerClass . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181 TheDoubleClass . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182 TheMathClass . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183 Random Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184 Multiple-Choice Questions on Standard Classes . . . . . . . . . . . . . . . . . 187 Answer Key . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200 Answers Explained . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200

Chapter 5. Program Design and Analysis207

The Software Development Life Cycle . . . . . . . . . . . . . . . . . . . . . . . 207 The Waterfall Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207 Program Specication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208 Program Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208 Program Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208 Testing and Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208 Program Maintenance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210 Object-Oriented Program Design . . . . . . . . . . . . . . . . . . . . . . . . . . 210 Identifying Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210 Identifying Behaviors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211 Determining Relationships Between Classes . . . . . . . . . . . . . . . . . . 211 UML Diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212 Implementing Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212 Implementing Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213 Vocabulary Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219 Program Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219 Program Correctness . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219 Assertions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219 Efciency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220 Multiple-Choice Questions on Program Design and Analysis . . . . . . . . 221 Answer Key . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230 Answers Explained . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230

Chapter 6. Arrays and Array Lists233

One-Dimensional Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233 Initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233 Length of Array . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234 Traversing an Array . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235 Arrays as Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235 Array Variables in a Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238 Array of Class Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239 Analyzing Array Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240 Array Lists. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241 The Collections API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241 The Collections Hierarchy. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242 Collections and Generics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242 Auto-Boxing and -Unboxing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242 TheListInterface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243 i i “ap" — 2014/11/4— 11:10 — page vi — #6i i i i i i viContents The Methods ofList. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243 TheArrayListClass . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244 UsingArrayList. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245 Collections and Iterators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247 Denition of an Iterator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247 TheIteratorInterface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247 Using a Generic Iterator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247 Two-Dimensional Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249 Declarations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250 Matrix as Array of Row Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . 250 Processing a Two-Dimensional Array . . . . . . . . . . . . . . . . . . . . . . . 251 Two-Dimensional Array as Parameter . . . . . . . . . . . . . . . . . . . . . . 253 Multiple-Choice Questions on Arrays and Array Lists . . . . . . . . . . . . 255 Answer Key . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284 Answers Explained . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284

Chapter 7. Recursion290

Recursive Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290 General Form of Simple Recursive Methods . . . . . . . . . . . . . . . . . . . 291 Writing Recursive Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293 Analysis of Recursive Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294 Sorting Algorithms That Use Recursion . . . . . . . . . . . . . . . . . . . . . . 295 Recursive Helper Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295 Recursion in Two-Dimensional Grids . . . . . . . . . . . . . . . . . . . . . . . . 298 Sample Free-Response Question 1 . . . . . . . . . . . . . . . . . . . . . . . . . 300 Sample Free-Response Question 2 . . . . . . . . . . . . . . . . . . . . . . . . . 303 Multiple-Choice Questions on Recursion . . . . . . . . . . . . . . . . . . . . . 308 Answer Key . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319 Answers Explained . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319

Chapter 8. Sorting and Searching324

Sorts: Selection and Insertion Sorts . . . . . . . . . . . . . . . . . . . . . . . . . 324 Selection Sort . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324 Insertion Sort . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325 Recursive Sorts: Mergesort and Quicksort . . . . . . . . . . . . . . . . . . . . 325 Mergesort . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325 Quicksort . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327 Sorting Algorithms in Java. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328 Sequential Search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329 Binary Search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329 Multiple-Choice Questions on Sorting and Searching . . . . . . . . . . . . . 331 Answer Key . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346 Answers Explained . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346

Chapter 9. The AP Computer Science A Labs351

The Magpie Lab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351 Special Emphasis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352 The Elevens Lab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353 Special Emphasis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 354 i i “ap" — 2014/11/4— 11:10 — page vii — #7i i i i i i

Contentsvii

The Picture Lab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 356 Special Emphasis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 356 Multiple-Choice Questions on the Lab Concepts . . . . . . . . . . . . . . . . 360 Answer Key . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373 Answers Explained . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373

Practice Exams377

Practice Exam Two379

Computer Science Section I . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381 Computer Science Section II . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 408 Answer Key (Section I) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 420 Answers Explained . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 420

Practice Exam Three433

Computer Science Section I . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 435 Computer Science Section II . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 460 Answer Key (Section I) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 472 Answers Explained . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 472

AAppendix: Glossary of Useful Computer Terms482

Index485

i i “ap" — 2014/11/4— 11:10 — page viii — #8 i i i i i i 5

Barron'sEssential

As you review the content in this book to work toward earning that5on your AP Computer Science A exam, here are five things that youMUSTknow above everything else:

1The Basics.Every AP exam question uses at least one of these:

Types and Identifiers (p. 60)

Operators (p. 63)

Control structures (p. 69)

2Objects, Classes, and Inheritance.You may have to write your own class.

You'll definitely need to interpret at least one class that's given.

Methods (p. 95)

Subclasses (p. 131)

Abstract classes (p. 142)

Interfaces (p. 144)

3Lists and Arrays.Learn to manipulate a list. Search, delete an item, insert an

item. It seems as if every second question on the AP exam uses a list!

One-dimensional arrays (p. 233)

ArrayLists (p. 244)

4 Two-dimensional Arrays.Learnto manipulate a matrix. Thistopic has become more prominent on the AP exam in recent years.

Two-dimensional arrays (p. 249)

Row-column traversal (p. 251)

for-each loop traversal (p. 251)

Row-by-row array processing (p. 251)

quotesdbs_dbs20.pdfusesText_26