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

Multiple-Choice Questions on Introductory Java Language Concepts took time to write to me with suggestions for the new edition, including my code that can be replaced by a call to one of these methods, you will probably the bundling together of data fields and operations into a single unit, a class ( and shrink)



Previous PDF Next PDF





[PDF] Part I Multiple Choice Questions (3 points each): - Purdue Computer

so that an object can only perform actions that are defined for its class? Given the following method and class signatures: (c) B and C are not exception classes since they do not extend class Exception and therefore What is the result of the following code within a single class where all relevant code has been shown?



[PDF] Chapter 1-

member function can access private // data member radius return 3 14*radius* radius; } }; // main function int main() { // creating object of the class Circle obj;



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

Multiple-Choice Questions on Introductory Java Language Concepts took time to write to me with suggestions for the new edition, including my code that can be replaced by a call to one of these methods, you will probably the bundling together of data fields and operations into a single unit, a class ( and shrink)



The C# Programmers Study Guide (MCSD)

Trademarked names, logos, and images may appear in this book Code Challenges At the end, exam structured MCQs are given to test the capability of the reader based When we define a list of parameters in method's signature, it becomes Extension methods are only defined inside static class to extend the  



[PDF] Learning Python - Materials Physics Center

String Methods 172 String Method Examples: Changing Strings Assignment Creates References, Not Copies 251 Extended Sequence Unpacking in Python 3 0 284 Indicates a syntactic unit that should be replaced with real code when they are no longer used, and most can grow and shrink on demand As you'll



[PDF] A Course Material on OBJECT ORIENTED PROGRAMMING By Mr

Signature of HD Name: Mr UNIT II -BASIC CHARACTERISTICS OF OOP 2 1 Legacy migration of systems from C to C++ (30+ years of C code to migrate to C++ means jobs) Programmers can create user-defined types called classes This is similar to a normal function definition expect that it is enclosed within the



[PDF] Programming Visual BasicNET - Visual Chart

Visual Basic 6 code can't be compiled by the Visual Basic Literals of type String consist of characters enclosed within quotation-mark characters signature and return type as the interface's method, but they need not have the same name inseparable unit, then the three modules together form an assembly, but none 



[PDF] Question Bank of Class – 6 Computer Science - Stewart School

The development of computer languages can be classified into ______ categories 3 Ans Assembly language use symbolic codes called as mnemonic codes where as Chapter – 6, Scratch Programming – Introduction to game creation (Ans 1 Shrink, 2 Pen, 3 Script area, 4 Sprite list, 5 Horizontal and Vertical, 6



[PDF] QUESTION BANK - edudel

Finally I also extend my thanks to Dr (Mrs ) Suman Rekha, ADE (School) Make a separate notebook for English Do it sincerely You will surely come out Separate instruction are given with each section and question, wherever It is by such methods that new discoveries have been made (vi) Closing and signature



[PDF] Introduction to Programming Using Java

This book can be distributed in unmodified form with no restrictions Static import is covered briefly, as are variable arity methods If you have the source code for a Java program, and you want to run that It would be easy to extend it later to deal with other units These methods all have different signatures, such as:

[PDF] to find the optimal solution we apply

[PDF] to gain credibility with your audience in a business report

[PDF] to inquire the lost gun file in ncic use transaction qg

[PDF] to make a safe right hand turn you should do which of the following?

[PDF] to make applause add one letter

[PDF] to share music files

[PDF] to valide au scrabble

[PDF] to vibrate change one letter

[PDF] to what extent was the french and indian war a prelude to the american revolution

[PDF] to what other holiday does douglass compare the fourth of july

[PDF] toa 70 volt speakers

[PDF] toa speaker

[PDF] toa speakers review

[PDF] tobacco smudge

[PDF] toc gtu syllabus

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 towardquotesdbs_dbs17.pdfusesText_23