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.1
107
about 2 months ago
Preview (31 of 451)
Sign in to access the full document!
The Princeton Review Publishing Team
Rob Franek, Editor-in-Chief
David Soto, Senior Director, Data Operations
Stephen Koch, Senior Manager, Data Operations
Deborah Weber, Director of Production
Jason Ullmeyer, Production Design Manager
Jennifer Chapman, Senior Production Artist
Selena Coppock, Director of Editorial
Orion McBean, Senior Editor
Aaron Riccio, Senior Editor
Meave Shelton, Senior Editor
Chris Chimera, Editor
Patricia Murphy, Editor
Laura Rose, Editor
Isabelle Appleton, Editorial Assistant
Penguin Random House Publishing Team
Tom Russell, VP, Publisher
Alison Stoltzfus, Senior Director, Publishing
Brett Wright, Senior Editor
Emily Hoffman, Assistant Managing Editor
Ellen Reed, Production Manager
Suzanne Lee, Designer
Eugenia Lo, Publishing Assistant
The Princeton Review
110 East 42nd St, 7th Floor
New York, NY 10017
Copyright © 2023 by TPR Education IP Holdings, LLC. All rights reserved.
Published in the United States by Penguin Random House LLC, New York.
Terms of Service: The Princeton Review Online Companion Tools (“Student Tools”) for retail books are
available for only the two most recent editions of that book. Student Tools may be activated only once per
eligible book purchased for a total of 24 months of access. Activation of Student Tools more than once per
book is in direct violation of these Terms of Service and may result in discontinuation of access to Student
Tools Services.
The material in this book is up-to-date at the time of publication. However, changes may have been
instituted by the testing body in the test after this book was published.
If there are any important late-breaking developments, changes, or corrections to the materials in this book,
we will post that information online in the Student Tools. Register your book and check your Student Tools to
see if there are any updates posted there.
ISBN 9780593517055
Ebook ISBN 9780593517062
AP is a trademark registered and owned by the College Board, which is not affiliated with, and does not
endorse, this product.
The Princeton Review is not affiliated with Princeton University.
Editor: Chris Chimera
Production Editors: Ali Landreau, Sarah Litt
Production Artist: Jennifer Chapman
Content Developer: Ann Heltzel
Cover art by Konstantin Inozemtsev / Alamy Stock Photo
Cover design by Suzanne Lee
Photo selection and layout by Carling Design, Inc.
Rob Franek, Editor-in-Chief
David Soto, Senior Director, Data Operations
Stephen Koch, Senior Manager, Data Operations
Deborah Weber, Director of Production
Jason Ullmeyer, Production Design Manager
Jennifer Chapman, Senior Production Artist
Selena Coppock, Director of Editorial
Orion McBean, Senior Editor
Aaron Riccio, Senior Editor
Meave Shelton, Senior Editor
Chris Chimera, Editor
Patricia Murphy, Editor
Laura Rose, Editor
Isabelle Appleton, Editorial Assistant
Penguin Random House Publishing Team
Tom Russell, VP, Publisher
Alison Stoltzfus, Senior Director, Publishing
Brett Wright, Senior Editor
Emily Hoffman, Assistant Managing Editor
Ellen Reed, Production Manager
Suzanne Lee, Designer
Eugenia Lo, Publishing Assistant
The Princeton Review
110 East 42nd St, 7th Floor
New York, NY 10017
Copyright © 2023 by TPR Education IP Holdings, LLC. All rights reserved.
Published in the United States by Penguin Random House LLC, New York.
Terms of Service: The Princeton Review Online Companion Tools (“Student Tools”) for retail books are
available for only the two most recent editions of that book. Student Tools may be activated only once per
eligible book purchased for a total of 24 months of access. Activation of Student Tools more than once per
book is in direct violation of these Terms of Service and may result in discontinuation of access to Student
Tools Services.
The material in this book is up-to-date at the time of publication. However, changes may have been
instituted by the testing body in the test after this book was published.
If there are any important late-breaking developments, changes, or corrections to the materials in this book,
we will post that information online in the Student Tools. Register your book and check your Student Tools to
see if there are any updates posted there.
ISBN 9780593517055
Ebook ISBN 9780593517062
AP is a trademark registered and owned by the College Board, which is not affiliated with, and does not
endorse, this product.
The Princeton Review is not affiliated with Princeton University.
Editor: Chris Chimera
Production Editors: Ali Landreau, Sarah Litt
Production Artist: Jennifer Chapman
Content Developer: Ann Heltzel
Cover art by Konstantin Inozemtsev / Alamy Stock Photo
Cover design by Suzanne Lee
Photo selection and layout by Carling Design, Inc.
Loading page 4...
For customer service, please contact editorialsupport@review.com, and be sure to
include:
• full title of the book
• ISBN
• page number
a_prh_6.0_144897283_c0_r0
include:
• full title of the book
• ISBN
• page number
a_prh_6.0_144897283_c0_r0
Loading page 5...
Acknowledgments
Special thanks to Ann Heltzel for her superb content development work on
the 8th edition of this book. Additionally, The Princeton Review would like to
thank Jennifer Chapman, Ali Landreau, and Sarah Litt for their contributions
to this title.
Special thanks to Ann Heltzel for her superb content development work on
the 8th edition of this book. Additionally, The Princeton Review would like to
thank Jennifer Chapman, Ali Landreau, and Sarah Litt for their contributions
to this title.
Loading page 6...
Contents
Get More (Free) Content
Part I: Using This Book to Improve Your AP Score
Preview: Your Knowledge, Your Expectations
Your Guide to Using This Book
How to Begin
Part II: Practice Test 1
Practice Test 1
Practice Test 1: Diagnostic Answer Key and Explanations
How to Score Practice Test 1
Part III: About the AP Computer Science A Exam
The Structure of the AP Computer Science A Exam
How AP Exams Are Used
Other Resources
Have You Heard About AP Computer Science Principles?
In Conclusion
Part IV: Test-Taking Strategies for the AP Computer
Science A Exam
Preview
1 How to Approach Multiple-Choice Questions
2 How to Approach Free-Response Questions
Reflect
Part V: Content Review for the AP Computer Science A
Exam
3 Primitive Types
Programming Style
Comments, Identifiers, White Space
Compiling & Errors
Objects & Primitive Data
Output (and Some Input)
Variables & Assignment
The Four Data Types—int, double, boolean, char
Get More (Free) Content
Part I: Using This Book to Improve Your AP Score
Preview: Your Knowledge, Your Expectations
Your Guide to Using This Book
How to Begin
Part II: Practice Test 1
Practice Test 1
Practice Test 1: Diagnostic Answer Key and Explanations
How to Score Practice Test 1
Part III: About the AP Computer Science A Exam
The Structure of the AP Computer Science A Exam
How AP Exams Are Used
Other Resources
Have You Heard About AP Computer Science Principles?
In Conclusion
Part IV: Test-Taking Strategies for the AP Computer
Science A Exam
Preview
1 How to Approach Multiple-Choice Questions
2 How to Approach Free-Response Questions
Reflect
Part V: Content Review for the AP Computer Science A
Exam
3 Primitive Types
Programming Style
Comments, Identifiers, White Space
Compiling & Errors
Objects & Primitive Data
Output (and Some Input)
Variables & Assignment
The Four Data Types—int, double, boolean, char
Loading page 7...
Arithmetic Operations
Key Terms
Chapter 3 Review Drill
Summary
4 Using Classes and Objects
The Math Class
The String Class
Key Terms
Chapter 4 Review Drill
Summary
5 Boolean Expressions and if Statements
The if Statement
Key Terms
Chapter 5 Review Drill
Summary
6 Iteration
The while Statement
The for Statement
Key Terms
Chapter 6 Review Drill
Summary
7 Writing Classes
Design & Structure
Methods
Composition
References
Static Modifier
Key Terms
Chapter 7 Review Drill
Summary
8 Array
Primitives & Objects
Searches
Sorts
Implementation of a Selection Sort
Implementation of an Insertion Sort
Implementation of a Merge Sort
Key Terms
Chapter 3 Review Drill
Summary
4 Using Classes and Objects
The Math Class
The String Class
Key Terms
Chapter 4 Review Drill
Summary
5 Boolean Expressions and if Statements
The if Statement
Key Terms
Chapter 5 Review Drill
Summary
6 Iteration
The while Statement
The for Statement
Key Terms
Chapter 6 Review Drill
Summary
7 Writing Classes
Design & Structure
Methods
Composition
References
Static Modifier
Key Terms
Chapter 7 Review Drill
Summary
8 Array
Primitives & Objects
Searches
Sorts
Implementation of a Selection Sort
Implementation of an Insertion Sort
Implementation of a Merge Sort
Loading page 8...
Key Terms
Chapter 8 Review Drill
Summary
9 ArrayList
Lists & ArrayLists
Arrays versus ArrayList Chart
Key Terms
Chapter 9 Review Drill
Summary
10 2D Arrays
2D Arrays
Key Terms
Chapter 10 Review Drill
Summary
11 Inheritance
Hierarchies & Design
Polymorphism
Key Terms
Chapter 11 Review Drill
Summary
12 Recursion
Recursion
Recursively Traversing Arrays
Key Terms
Chapter 12 Review Drill
Summary
13 Chapter Review Drill Answers and Explanations
14 Required Lab Time and Suggested Labs
Part VI: Practice Tests
Practice Test 2
Practice Test 2: Answers and Explanations
How to Score Practice Test 2
Practice Test 3
Practice Test 3: Answers and Explanations
How to Score Practice Test 3
Chapter 8 Review Drill
Summary
9 ArrayList
Lists & ArrayLists
Arrays versus ArrayList Chart
Key Terms
Chapter 9 Review Drill
Summary
10 2D Arrays
2D Arrays
Key Terms
Chapter 10 Review Drill
Summary
11 Inheritance
Hierarchies & Design
Polymorphism
Key Terms
Chapter 11 Review Drill
Summary
12 Recursion
Recursion
Recursively Traversing Arrays
Key Terms
Chapter 12 Review Drill
Summary
13 Chapter Review Drill Answers and Explanations
14 Required Lab Time and Suggested Labs
Part VI: Practice Tests
Practice Test 2
Practice Test 2: Answers and Explanations
How to Score Practice Test 2
Practice Test 3
Practice Test 3: Answers and Explanations
How to Score Practice Test 3
Loading page 9...
Online Practice Tests
Glossary
_144897283_
Glossary
_144897283_
Loading page 10...
Online Practice Tests
Click here to go to the online supplement for this book.
• Practice Test 4
• Practice Test 4: Answers and Explanations
• Practice Test 5
• Practice Test 5: Answers and Explanations
Click here to go to the online supplement for this book.
• Practice Test 4
• Practice Test 4: Answers and Explanations
• Practice Test 5
• Practice Test 5: Answers and Explanations
Loading page 11...
1 Go to PrincetonReview.com/prep and enter the following ISBN for your
book: 9780593517062
2 Answer a few simple questions to set up an exclusive Princeton
Review account. (If you already have one, you can just log in.)
3 Enjoy access to your FREE content!
Need to report a potential content issue?
Contact EditorialSupport@review.com and include:
• full title of the book
• ISBN
• page number
Need to report a technical issue?
Contact TPRStudentTech@review.com and provide:
• your full name
• email address used to register the book
• full book title and ISBN
• Operating system (Mac/PC) and browser (Chrome, Firefox, Safari, etc.)
Once you’ve registered, you can…
• Take a full-length practice SAT and ACT
• Access Practice Tests 4 and 5 plus detailed Answers and Explanations
• Get valuable advice about the college application process, including
tips for writing a great essay and where to apply for financial aid
• If you’re still choosing between colleges, use our searchable rankings of
The Best 389 Colleges to find out more information about your dream
school
• Access comprehensive study guides and a variety of printable
resources including AP Score Conversion charts, Key Terms lists, and
the Glossary
• Check to see if there have been any corrections or updates to this
edition
book: 9780593517062
2 Answer a few simple questions to set up an exclusive Princeton
Review account. (If you already have one, you can just log in.)
3 Enjoy access to your FREE content!
Need to report a potential content issue?
Contact EditorialSupport@review.com and include:
• full title of the book
• ISBN
• page number
Need to report a technical issue?
Contact TPRStudentTech@review.com and provide:
• your full name
• email address used to register the book
• full book title and ISBN
• Operating system (Mac/PC) and browser (Chrome, Firefox, Safari, etc.)
Once you’ve registered, you can…
• Take a full-length practice SAT and ACT
• Access Practice Tests 4 and 5 plus detailed Answers and Explanations
• Get valuable advice about the college application process, including
tips for writing a great essay and where to apply for financial aid
• If you’re still choosing between colleges, use our searchable rankings of
The Best 389 Colleges to find out more information about your dream
school
• Access comprehensive study guides and a variety of printable
resources including AP Score Conversion charts, Key Terms lists, and
the Glossary
• Check to see if there have been any corrections or updates to this
edition
Loading page 12...
• Get our take on any recent or pending updates to the AP Computer
Science A Exam
Look For These Icons Throughout The
Book
PROVEN TECHNIQUES
APPLIED STRATEGIES
STUDY BREAK
OTHER REFERENCES
ONLINE ARTICLES
ONLINE VIDEO TUTORIALS
Science A Exam
Look For These Icons Throughout The
Book
PROVEN TECHNIQUES
APPLIED STRATEGIES
STUDY BREAK
OTHER REFERENCES
ONLINE ARTICLES
ONLINE VIDEO TUTORIALS
Loading page 13...
Loading page 14...
Part I
Using This Book to Improve Your AP
Score
• Preview: Your Knowledge, Your Expectations
• Your Guide to Using This Book
• How to Begin
Using This Book to Improve Your AP
Score
• Preview: Your Knowledge, Your Expectations
• Your Guide to Using This Book
• How to Begin
Loading page 15...
PREVIEW: YOUR KNOWLEDGE, YOUR
EXPECTATIONS
Your route to a high score on the AP Computer Science A Exam depends a lot on
how you plan to use this book. Start thinking about your plan by responding to the
following questions.
1. Rate your level of confidence in your knowledge of the content tested by the
AP Computer Science A Exam:
A. Very confident—I know it all.
B. I’m pretty confident, but there are topics with which I could use help.
C. Not confident—I need quite a bit of support.
D. I’m not sure.
2. If you have a goal score in mind, choose it for the AP Computer Science A
Exam:
5 4 3 2 1 I’m not sure yet.
3. What do you expect to learn from this book? Choose all that apply to you.
A. A general overview of the test and what to expect
B. Strategies for how to approach the test
C. The content tested by this exam
D. I’m not sure yet.
YOUR GUIDE TO USING THIS BOOK
This book is organized to provide as much—or as little—support as you need, so you
can use this book in whatever way will be most helpful to improving your score on
the AP Computer Science A Exam.
• The remainder of Part I will provide guidance on how to use this book and
help you determine your strengths and weaknesses.
• Part II of this book contains your first practice test, a Diagnostic Answer Key,
detailed answers and explanations for each question, and a scoring guide. We
recommend that you take this test before going any further in order to
realistically determine:
◦ your starting point right now
◦ which question types you’re ready for and which you might need to
practice
◦ which content topics you are familiar with and which you should review
carefully
EXPECTATIONS
Your route to a high score on the AP Computer Science A Exam depends a lot on
how you plan to use this book. Start thinking about your plan by responding to the
following questions.
1. Rate your level of confidence in your knowledge of the content tested by the
AP Computer Science A Exam:
A. Very confident—I know it all.
B. I’m pretty confident, but there are topics with which I could use help.
C. Not confident—I need quite a bit of support.
D. I’m not sure.
2. If you have a goal score in mind, choose it for the AP Computer Science A
Exam:
5 4 3 2 1 I’m not sure yet.
3. What do you expect to learn from this book? Choose all that apply to you.
A. A general overview of the test and what to expect
B. Strategies for how to approach the test
C. The content tested by this exam
D. I’m not sure yet.
YOUR GUIDE TO USING THIS BOOK
This book is organized to provide as much—or as little—support as you need, so you
can use this book in whatever way will be most helpful to improving your score on
the AP Computer Science A Exam.
• The remainder of Part I will provide guidance on how to use this book and
help you determine your strengths and weaknesses.
• Part II of this book contains your first practice test, a Diagnostic Answer Key,
detailed answers and explanations for each question, and a scoring guide. We
recommend that you take this test before going any further in order to
realistically determine:
◦ your starting point right now
◦ which question types you’re ready for and which you might need to
practice
◦ which content topics you are familiar with and which you should review
carefully
Loading page 16...
It’s Bubble Time
Bubble sheets for the tests in this book can be
found online—you can print them from your online
student tools. We highly recommend that you do
so before taking a practice test, as learning how
to transfer your answers to a bubble sheet is an
important part of preparing for the test.
Once you have nailed down your strengths and weaknesses with regard to this
exam, you can focus your test preparation, build a study plan, and be efficient
with your time. Our Diagnostic Answer Key will assist you with this process.
• Part III of this book will:
◦ provide information about the structure, scoring, and content of the AP
Computer Science A Exam
◦ help you to make a study plan
◦ point you toward additional resources
• Part IV of this book will explore various strategies, including:
◦ how to attack multiple-choice questions
◦ how to effectively answer free-response questions
◦ how to manage your time to maximize the number of points available to
you
• Part V of this book covers the content you need to know for the AP Computer
Science A Exam.
• Part VI of this book contains Practice Tests 2 and 3, plus their answers and
explanations, and a scoring guide. (Practice Tests 4 and 5 and their answers
and explanations can be found online.) We recommend that you pepper in
Practice Tests as you study for your exam. Don’t take all the Practice Tests in a
row or even in rapid succession: start with Practice Test 1 to get a sense of
where you are. Then, as you complete your content review, take a Practice Test
every so often to see how you are doing and whether you are improving or
need to review certain topics.
You may choose to use some parts of this book over others, or you may work through
the entire book. Your approach will depend on your needs and how much time you
have. Now, let’s look at how to make this determination.
HOW TO BEGIN
1. Take Practice Test 1
Before you can decide how to use this book, you need to take a practice test.
Doing so will give you insight into your strengths and weaknesses, and the
Bubble sheets for the tests in this book can be
found online—you can print them from your online
student tools. We highly recommend that you do
so before taking a practice test, as learning how
to transfer your answers to a bubble sheet is an
important part of preparing for the test.
Once you have nailed down your strengths and weaknesses with regard to this
exam, you can focus your test preparation, build a study plan, and be efficient
with your time. Our Diagnostic Answer Key will assist you with this process.
• Part III of this book will:
◦ provide information about the structure, scoring, and content of the AP
Computer Science A Exam
◦ help you to make a study plan
◦ point you toward additional resources
• Part IV of this book will explore various strategies, including:
◦ how to attack multiple-choice questions
◦ how to effectively answer free-response questions
◦ how to manage your time to maximize the number of points available to
you
• Part V of this book covers the content you need to know for the AP Computer
Science A Exam.
• Part VI of this book contains Practice Tests 2 and 3, plus their answers and
explanations, and a scoring guide. (Practice Tests 4 and 5 and their answers
and explanations can be found online.) We recommend that you pepper in
Practice Tests as you study for your exam. Don’t take all the Practice Tests in a
row or even in rapid succession: start with Practice Test 1 to get a sense of
where you are. Then, as you complete your content review, take a Practice Test
every so often to see how you are doing and whether you are improving or
need to review certain topics.
You may choose to use some parts of this book over others, or you may work through
the entire book. Your approach will depend on your needs and how much time you
have. Now, let’s look at how to make this determination.
HOW TO BEGIN
1. Take Practice Test 1
Before you can decide how to use this book, you need to take a practice test.
Doing so will give you insight into your strengths and weaknesses, and the
Loading page 17...
test will also help you make an effective study plan. If you’re feeling test-
phobic, remind yourself that a practice test is a tool for diagnosing yourself—
it’s not how well you do that matters but how you use information gleaned
from your performance to guide your preparation.
So, before you read further, take Practice Test 1 starting on this page of this
book. Be sure to finish it in one sitting, following the instructions that appear
before the test.
2. Check Your Answers
Using the Diagnostic Answer Key on this page, follow our three-step process
to identify your strengths and weaknesses with regard to the tested topics.
This will help you determine which content review chapters to prioritize
when studying this book. Don’t worry about the explanations for now, and
don’t worry about missed questions. We’ll get to that soon.
Bonus Tips and Tricks…
Check us out on YouTube for test-taking tips and
tricks to help you ace your next exam at
www.youtube.com/ThePrincetonReview
3. Reflect on the Test
After you take your first test, respond to the following questions:
• How much time did you spend on the multiple-choice questions?
• How much time did you spend on each free-response question?
• How many multiple-choice questions did you answer correctly and how
many did you miss?
• Do you feel you had the knowledge to address the subject matter of the
free-response questions?
4. Read Part III of this Book and Complete the Self-Evaluation
Part III will provide information on how the test is structured and scored. It
will also set out areas of content that are tested.
As you read Part III, re-evaluate your answers to the questions above. At the
end of Part III, you will revisit and refine those questions. You will then be
able to make a study plan, based on your needs and available time, that will
allow you to use this book most effectively.
5. Engage with Parts IV and V as Needed
phobic, remind yourself that a practice test is a tool for diagnosing yourself—
it’s not how well you do that matters but how you use information gleaned
from your performance to guide your preparation.
So, before you read further, take Practice Test 1 starting on this page of this
book. Be sure to finish it in one sitting, following the instructions that appear
before the test.
2. Check Your Answers
Using the Diagnostic Answer Key on this page, follow our three-step process
to identify your strengths and weaknesses with regard to the tested topics.
This will help you determine which content review chapters to prioritize
when studying this book. Don’t worry about the explanations for now, and
don’t worry about missed questions. We’ll get to that soon.
Bonus Tips and Tricks…
Check us out on YouTube for test-taking tips and
tricks to help you ace your next exam at
www.youtube.com/ThePrincetonReview
3. Reflect on the Test
After you take your first test, respond to the following questions:
• How much time did you spend on the multiple-choice questions?
• How much time did you spend on each free-response question?
• How many multiple-choice questions did you answer correctly and how
many did you miss?
• Do you feel you had the knowledge to address the subject matter of the
free-response questions?
4. Read Part III of this Book and Complete the Self-Evaluation
Part III will provide information on how the test is structured and scored. It
will also set out areas of content that are tested.
As you read Part III, re-evaluate your answers to the questions above. At the
end of Part III, you will revisit and refine those questions. You will then be
able to make a study plan, based on your needs and available time, that will
allow you to use this book most effectively.
5. Engage with Parts IV and V as Needed
Loading page 18...
Notice the word engage. You’ll get more out of this book if you use it
intentionally than if you read it passively, hoping for an improved score
through osmosis.
The strategy chapters will help you think about your approach to the question
types on this exam. Part IV will open with a reminder to think about how you
approach questions now and then close with a reflection section asking you to
think about how or whether you will change your approach in the future.
The content chapters in Part V are designed to provide a review of the content
tested on the AP Computer Science A Exam, including the level of detail you
need to know and how the content is tested. In addition, the content chapters
are broken up to exactly match the 10-unit structure of the AP Computer
Science A course, as outlined by the College Board.
You will have the opportunity to assess your proficiency in the content of
each chapter through test-appropriate questions and a reflection section.
6. Take Practice Tests 2, 3, 4, and 5 and Assess Your Performance
Once you feel you have developed the strategies you need and gained the
knowledge you lacked, you should take Practice Test 2, which starts on this
page of this book. You should do so in one sitting, following the instructions
at the beginning of the test.
When you are finished, check your answers to the multiple-choice sections.
See whether a teacher or friend will read your free-response answers, provide
feedback, and go over them with you.
Once you have taken the test, reflect on the areas on which you still need
work, and revisit the chapters in this book that address those deficiencies.
Then go back and take Practice Test 3 and do the same, then Practice Test 4,
then Practice Test 5. You have 5 practice tests with this book—be sure to
make use of all of them! (Note that Practice Tests 4 and 5 are online PDFs
found in your Student Tools. Go back a few pages for step-by-step directions
on how to register your book and access all of your online resources.)
Need Some Guidance?
If you’re looking for a way to get the most out of your
studying, check out our free study guide for this
exam, which you can access via your online student
tools. See the “Get More (Free) Content” page for
details on accessing this great resource and more.
7. Keep Working
intentionally than if you read it passively, hoping for an improved score
through osmosis.
The strategy chapters will help you think about your approach to the question
types on this exam. Part IV will open with a reminder to think about how you
approach questions now and then close with a reflection section asking you to
think about how or whether you will change your approach in the future.
The content chapters in Part V are designed to provide a review of the content
tested on the AP Computer Science A Exam, including the level of detail you
need to know and how the content is tested. In addition, the content chapters
are broken up to exactly match the 10-unit structure of the AP Computer
Science A course, as outlined by the College Board.
You will have the opportunity to assess your proficiency in the content of
each chapter through test-appropriate questions and a reflection section.
6. Take Practice Tests 2, 3, 4, and 5 and Assess Your Performance
Once you feel you have developed the strategies you need and gained the
knowledge you lacked, you should take Practice Test 2, which starts on this
page of this book. You should do so in one sitting, following the instructions
at the beginning of the test.
When you are finished, check your answers to the multiple-choice sections.
See whether a teacher or friend will read your free-response answers, provide
feedback, and go over them with you.
Once you have taken the test, reflect on the areas on which you still need
work, and revisit the chapters in this book that address those deficiencies.
Then go back and take Practice Test 3 and do the same, then Practice Test 4,
then Practice Test 5. You have 5 practice tests with this book—be sure to
make use of all of them! (Note that Practice Tests 4 and 5 are online PDFs
found in your Student Tools. Go back a few pages for step-by-step directions
on how to register your book and access all of your online resources.)
Need Some Guidance?
If you’re looking for a way to get the most out of your
studying, check out our free study guide for this
exam, which you can access via your online student
tools. See the “Get More (Free) Content” page for
details on accessing this great resource and more.
7. Keep Working
Loading page 19...
As mentioned earlier, there are other resources available to you, including a
wealth of information on the AP Students website
(apstudent.collegeboard.org/apcourse/ap-computer-science-a). On this site,
you can continue to explore areas that you could improve upon and engage in
those areas right up until the day of the test. You should use a mix of web
resources and book review to solidify your understanding of any question
subjects that you keep getting wrong.
wealth of information on the AP Students website
(apstudent.collegeboard.org/apcourse/ap-computer-science-a). On this site,
you can continue to explore areas that you could improve upon and engage in
those areas right up until the day of the test. You should use a mix of web
resources and book review to solidify your understanding of any question
subjects that you keep getting wrong.
Loading page 20...
Part II
Practice Test 1
• Practice Test 1
• Practice Test 1: Diagnostic Answer Key and Explanations
• How to Score Practice Test 1
Practice Test 1
• Practice Test 1
• Practice Test 1: Diagnostic Answer Key and Explanations
• How to Score Practice Test 1
Loading page 21...
Practice Test 1
Click here to download a PDF of Practice Test 1.
Click here to download a PDF of Practice Test 1.
Loading page 22...
Section I
The Exam
AP® Computer Science A Exam
SECTION I: Multiple-Choice Questions
DO NOT OPEN THIS BOOKLET UNTIL YOU ARE TOLD TO DO SO.
At a Glance
Total Time
1 hour 30 minutes
Number of Questions
40
Percent of Total Score
50%
Writing Instrument
Pencil required
Instructions
Section I of this examination contains 40 multiple-choice questions. Fill in only the
ovals for numbers 1 through 40 on your answer sheet.
Indicate all of your answers to the multiple-choice questions on the answer sheet.
No credit will be given for anything written in this exam booklet, but you may use
the booklet for notes or scratch work. After you have decided which of the
suggested answers is best, completely fill in the corresponding oval on the answer
sheet. Give only one answer to each question. If you change an answer, be sure that
the previous mark is erased completely. Here is a sample question and answer.
Sample Question
Chicago is a
(A) state
(B) city
(C) country
(D) continent
(E) county
Sample Answer
The Exam
AP® Computer Science A Exam
SECTION I: Multiple-Choice Questions
DO NOT OPEN THIS BOOKLET UNTIL YOU ARE TOLD TO DO SO.
At a Glance
Total Time
1 hour 30 minutes
Number of Questions
40
Percent of Total Score
50%
Writing Instrument
Pencil required
Instructions
Section I of this examination contains 40 multiple-choice questions. Fill in only the
ovals for numbers 1 through 40 on your answer sheet.
Indicate all of your answers to the multiple-choice questions on the answer sheet.
No credit will be given for anything written in this exam booklet, but you may use
the booklet for notes or scratch work. After you have decided which of the
suggested answers is best, completely fill in the corresponding oval on the answer
sheet. Give only one answer to each question. If you change an answer, be sure that
the previous mark is erased completely. Here is a sample question and answer.
Sample Question
Chicago is a
(A) state
(B) city
(C) country
(D) continent
(E) county
Sample Answer
Loading page 23...
Use your time effectively, working as quickly as you can without losing accuracy.
Do not spend too much time on any one question. Go on to other questions and
come back to the ones you have not answered if you have time. It is not expected
that everyone will know the answers to all the multiple-choice questions.
About Guessing
Many candidates wonder whether or not to guess the answers to questions about
which they are not certain. Multiple-choice scores are based on the number of
questions answered correctly. Points are not deducted for incorrect answers, and no
points are awarded for unanswered questions. Because points are not deducted for
incorrect answers, you are encouraged to answer all multiple-choice questions. On
any questions you do not know the answer to, you should eliminate as many
choices as you can, and then select the best answer among the remaining choices.
Do not spend too much time on any one question. Go on to other questions and
come back to the ones you have not answered if you have time. It is not expected
that everyone will know the answers to all the multiple-choice questions.
About Guessing
Many candidates wonder whether or not to guess the answers to questions about
which they are not certain. Multiple-choice scores are based on the number of
questions answered correctly. Points are not deducted for incorrect answers, and no
points are awarded for unanswered questions. Because points are not deducted for
incorrect answers, you are encouraged to answer all multiple-choice questions. On
any questions you do not know the answer to, you should eliminate as many
choices as you can, and then select the best answer among the remaining choices.
Loading page 24...
Java Quick Reference
Class Constructors and
Methods
Explanation
String Class
String(String
str)
Constructs a new String object that represents the
same sequence of characters as str
int length() Returns the number of characters in a String object
String
substring(int
from, int to)
Returns the substring beginning at index from and
ending at index to – 1
String
substring(int
from)
Returns substring(from, length())
int
indexOf(String
str)
Returns the index of the first occurrence of str;
returns –1 if not found
boolean
equals(String
other)
Returns true if this is equal to other; returns
false otherwise
int
compareTo(String
other)
Returns a value <0 if this is less than other;
returns zero if this is equal to other; returns a
value >0 if this is greater than other
Integer Class
Integer(int
value)
Constructs a new Integer object that represents the
specified int value
Integer.MIN_VALUE The minimum value represented by an int or
Integer
Integer.MAX_VALUE The maximum value represented by an int or
Integer
int intValue() Returns the value of this Integer as an int
Double Class
Double(double
value)
Constructs a new Double object that represents the
specified double value
double
doubleValue()
Returns the value of this Double as a double
Class Constructors and
Methods
Explanation
String Class
String(String
str)
Constructs a new String object that represents the
same sequence of characters as str
int length() Returns the number of characters in a String object
String
substring(int
from, int to)
Returns the substring beginning at index from and
ending at index to – 1
String
substring(int
from)
Returns substring(from, length())
int
indexOf(String
str)
Returns the index of the first occurrence of str;
returns –1 if not found
boolean
equals(String
other)
Returns true if this is equal to other; returns
false otherwise
int
compareTo(String
other)
Returns a value <0 if this is less than other;
returns zero if this is equal to other; returns a
value >0 if this is greater than other
Integer Class
Integer(int
value)
Constructs a new Integer object that represents the
specified int value
Integer.MIN_VALUE The minimum value represented by an int or
Integer
Integer.MAX_VALUE The maximum value represented by an int or
Integer
int intValue() Returns the value of this Integer as an int
Double Class
Double(double
value)
Constructs a new Double object that represents the
specified double value
double
doubleValue()
Returns the value of this Double as a double
Loading page 25...
Math Class
static int
abs(int x)
Returns the absolute value of an int value
static double
abs(double x)
Returns the absolute value of a double value
static double
pow(double base,
double exponent)
Returns the value of the first parameter raised to the
power of the second parameter
static double
sqrt(double x)
Returns the positive square root of a double value
static double
random()
Returns a double value greater than or equal to 0.0
and less than 1.0
ArrayList Class
int size() Returns the number of elements in the list
boolean add(E
obj)
Appends obj to end of list; returns true
void add(int
index, E obj)
Inserts obj at position index (0 <= index <=
size), moving elements at position index and
higher to the right (adds 1 to their indices) and adds 1
to size
E get(int index) Returns the element at position index in the list
E set(int index,
E obj)
Replaces the element at position index with obj;
returns the element formerly at position index
E remove(int
index)
Removes element from position index, moving
elements at position index + 1 and higher to the
left (subtracts 1 from their indices) and subtracts 1
from size; returns the element formerly at position
index
Object Class
boolean equals(Object other)
String toString()
static int
abs(int x)
Returns the absolute value of an int value
static double
abs(double x)
Returns the absolute value of a double value
static double
pow(double base,
double exponent)
Returns the value of the first parameter raised to the
power of the second parameter
static double
sqrt(double x)
Returns the positive square root of a double value
static double
random()
Returns a double value greater than or equal to 0.0
and less than 1.0
ArrayList Class
int size() Returns the number of elements in the list
boolean add(E
obj)
Appends obj to end of list; returns true
void add(int
index, E obj)
Inserts obj at position index (0 <= index <=
size), moving elements at position index and
higher to the right (adds 1 to their indices) and adds 1
to size
E get(int index) Returns the element at position index in the list
E set(int index,
E obj)
Replaces the element at position index with obj;
returns the element formerly at position index
E remove(int
index)
Removes element from position index, moving
elements at position index + 1 and higher to the
left (subtracts 1 from their indices) and subtracts 1
from size; returns the element formerly at position
index
Object Class
boolean equals(Object other)
String toString()
Loading page 26...
Section I
COMPUTER SCIENCE A
SECTION I
Time—1 hour and 30 minutes
Number of Questions—40
Percent of total exam grade—50%
Directions: Determine the answer to each of the following questions or incomplete
statements, using the available space for any necessary scratchwork. Then decide
which is the best of the choices given and fill in the corresponding oval on the
answer sheet. No credit will be given for anything written in the examination
booklet. Do not spend too much time on any one problem.
Notes:
• Assume that the classes listed in the Quick Reference have been imported
where appropriate.
• Assume that declarations of variables and methods appear within the context of
an enclosing class.
• Assume that method calls that are not prefixed with an object or class name
and are not shown within a complete class definition appear within the context
of an enclosing class.
• Unless otherwise noted in the question, assume that parameters in the method
calls are not null and that methods are called only when their preconditions
are satisfied.
1. Evaluate the following expression: 4 + 6 % 12 / 4
(A) 1
(B) 2
(C) 4
(D) 4.5
(E) 5
2. Which of the following expressions does NOT evaluate to 0.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. Choose the code used to print the following:
COMPUTER SCIENCE A
SECTION I
Time—1 hour and 30 minutes
Number of Questions—40
Percent of total exam grade—50%
Directions: Determine the answer to each of the following questions or incomplete
statements, using the available space for any necessary scratchwork. Then decide
which is the best of the choices given and fill in the corresponding oval on the
answer sheet. No credit will be given for anything written in the examination
booklet. Do not spend too much time on any one problem.
Notes:
• Assume that the classes listed in the Quick Reference have been imported
where appropriate.
• Assume that declarations of variables and methods appear within the context of
an enclosing class.
• Assume that method calls that are not prefixed with an object or class name
and are not shown within a complete class definition appear within the context
of an enclosing class.
• Unless otherwise noted in the question, assume that parameters in the method
calls are not null and that methods are called only when their preconditions
are satisfied.
1. Evaluate the following expression: 4 + 6 % 12 / 4
(A) 1
(B) 2
(C) 4
(D) 4.5
(E) 5
2. Which of the following expressions does NOT evaluate to 0.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. Choose the code used to print the following:
Loading page 27...
“Friends”
(A) System.out.print(““Friends””);
(B) System.out.print(“//“Friends//””);
(C) System.out.print(“/“Friends/””);
(D) System.out.print(“\“Friends\””);
(E) System.out.print(“\\“Friends \\””);
4. Determine the output of the following code.
String animal1 = “elephant”;
String animal2 = “lion”;
swap(animal1, animal2);
animal1.toUpperCase();
animal2.toLowerCase();
System.out.println(animal1 + “ ” + animal2);
public static void swap(String a1, String a2) {
String hold = a1;
a1 = a2;
a2 = hold;
}
(A) elephant lion
(B) ELEPHANT lion
(C) lion elephant
(D) LION elephant
(E) LION ELEPHANT
Questions 5–6 refer to the Constellation class below.
public class Constellation
private String name;
private String month;
private int northernLatitude;
private int southernLatitude;
Constellation(String n, String m)
{
name = n;
month = m;
northernLatitude = 0;
southernLatitude = 0;
(A) System.out.print(““Friends””);
(B) System.out.print(“//“Friends//””);
(C) System.out.print(“/“Friends/””);
(D) System.out.print(“\“Friends\””);
(E) System.out.print(“\\“Friends \\””);
4. Determine the output of the following code.
String animal1 = “elephant”;
String animal2 = “lion”;
swap(animal1, animal2);
animal1.toUpperCase();
animal2.toLowerCase();
System.out.println(animal1 + “ ” + animal2);
public static void swap(String a1, String a2) {
String hold = a1;
a1 = a2;
a2 = hold;
}
(A) elephant lion
(B) ELEPHANT lion
(C) lion elephant
(D) LION elephant
(E) LION ELEPHANT
Questions 5–6 refer to the Constellation class below.
public class Constellation
private String name;
private String month;
private int northernLatitude;
private int southernLatitude;
Constellation(String n, String m)
{
name = n;
month = m;
northernLatitude = 0;
southernLatitude = 0;
Loading page 28...
}
Constellation(String n, String m, int nLat, int
sLat)
{
name = n;
month = m;
northernLatitude = nLat;
southernLatitude = sLat;
}
public void chgMonth(String m)
{
String month = m;
}
5. Using the Constellation class, which of the following will cause a
compiler error?
(A) Constellation c1 = new Constellation(“Hercules”,
“July”);
(B) Constellation c2 = new Constellation(“Pisces”,
“Nov”, 90, 65);
(C) Constellation c3 = new Constellation(“Aquarius”,
“Oct”, 65.0, 90.0);
(D) Constellation c4 = new Constellation(“Leo”, “4”,
0, 0);
(E) Constellation c5 = new Constellation(“Phoenix”,
“Nov”, 32, 90);
6. A programmer has attempted to add three mutator methods to the
Constellation class.
I. public void chgLatitude(String direction, int
latitude)
{
if (direction.toUpperCase().equals(“N”))
northernLatitude = latitude;
else if (direction.toUpperCase().equals(“S”))
southernLatitude = latitude;
}
II. public void chgLatitude(int nLatitude, int
sLatitude)
{
Constellation(String n, String m, int nLat, int
sLat)
{
name = n;
month = m;
northernLatitude = nLat;
southernLatitude = sLat;
}
public void chgMonth(String m)
{
String month = m;
}
5. Using the Constellation class, which of the following will cause a
compiler error?
(A) Constellation c1 = new Constellation(“Hercules”,
“July”);
(B) Constellation c2 = new Constellation(“Pisces”,
“Nov”, 90, 65);
(C) Constellation c3 = new Constellation(“Aquarius”,
“Oct”, 65.0, 90.0);
(D) Constellation c4 = new Constellation(“Leo”, “4”,
0, 0);
(E) Constellation c5 = new Constellation(“Phoenix”,
“Nov”, 32, 90);
6. A programmer has attempted to add three mutator methods to the
Constellation class.
I. public void chgLatitude(String direction, int
latitude)
{
if (direction.toUpperCase().equals(“N”))
northernLatitude = latitude;
else if (direction.toUpperCase().equals(“S”))
southernLatitude = latitude;
}
II. public void chgLatitude(int nLatitude, int
sLatitude)
{
Loading page 29...
northernLatitude = nLatitude;
southernLatitude = sLatitude;
}
III. public void chgLatitude(double nLatitude, double
sLatitude)
{
northernLatitude = (int) nLatitude;
southernLatitude = (int) sLatitude;
}
Which of the three will compile without a compiler error?
(A) I only
(B) II only
(C) III only
(D) I and II only
(E) I, II, and III
7. Determine the values of x and y after the following code runs.
int x = 10;
int y = 5;
if (x == 10)
{
if (y <= 5)
y++;
else if (y < 4)
x = 3;
else
y += 6;
}
if (y > 5)
{
if (x != 10)
{
x = 0;
y = 0;
}
else
x = -5;
}
(A) x = 0, y = 0
southernLatitude = sLatitude;
}
III. public void chgLatitude(double nLatitude, double
sLatitude)
{
northernLatitude = (int) nLatitude;
southernLatitude = (int) sLatitude;
}
Which of the three will compile without a compiler error?
(A) I only
(B) II only
(C) III only
(D) I and II only
(E) I, II, and III
7. Determine the values of x and y after the following code runs.
int x = 10;
int y = 5;
if (x == 10)
{
if (y <= 5)
y++;
else if (y < 4)
x = 3;
else
y += 6;
}
if (y > 5)
{
if (x != 10)
{
x = 0;
y = 0;
}
else
x = -5;
}
(A) x = 0, y = 0
Loading page 30...
(B) x = –5, y = 6
(C) x = 10, y = 5
(D) x = 3, y = 5
(E) None of the above
8. A programmer intended to write code to print three words in ascending
lexicographical order. Follow the code and determine the printed output.
1 String word1 = “frog”;
2 String word2 = “dog”;
3 String word3 = “cat”;
4
5 if (word1.compareTo(word2) < 0)
6 if (word2.compareTo(word3) < 0)
7 System.out.println(word1 + “ ” + word2 + “ ” +
word3);
8 else
9 System.out.println(word1 + “ ” + word3 + “ ” +
word2);
10 else
11 if (word1.compareTo(word2) > 0)
12 if (word2.compareTo(word3) < 0)
13 System.out.println(word1 + “ ” + word2 + “ ” +
word3);
14 else
15 System.out.println(word1 + “ ” + word3 + “ ” +
word2);
16 else
17 if (word2.equals(word3))
18 System.out.println(“all the words are the
same”);
19 else
20 System.out.println(“word1 and word2 are
duplicates”);
(A) frog cat dog
(B) cat dog frog
(C) dog frog cat
(D) frog dog cat
(E) dog cat frog
9. Using the following variable declarations, determine which of the following
would evaluate to true.
(C) x = 10, y = 5
(D) x = 3, y = 5
(E) None of the above
8. A programmer intended to write code to print three words in ascending
lexicographical order. Follow the code and determine the printed output.
1 String word1 = “frog”;
2 String word2 = “dog”;
3 String word3 = “cat”;
4
5 if (word1.compareTo(word2) < 0)
6 if (word2.compareTo(word3) < 0)
7 System.out.println(word1 + “ ” + word2 + “ ” +
word3);
8 else
9 System.out.println(word1 + “ ” + word3 + “ ” +
word2);
10 else
11 if (word1.compareTo(word2) > 0)
12 if (word2.compareTo(word3) < 0)
13 System.out.println(word1 + “ ” + word2 + “ ” +
word3);
14 else
15 System.out.println(word1 + “ ” + word3 + “ ” +
word2);
16 else
17 if (word2.equals(word3))
18 System.out.println(“all the words are the
same”);
19 else
20 System.out.println(“word1 and word2 are
duplicates”);
(A) frog cat dog
(B) cat dog frog
(C) dog frog cat
(D) frog dog cat
(E) dog cat frog
9. Using the following variable declarations, determine which of the following
would evaluate to true.
Loading page 31...
30 more pages available. Scroll down to load them.
Preview Mode
Sign in to access the full document!
100%
Study Now!
XY-Copilot AI
Unlimited Access
Secure Payment
Instant Access
24/7 Support
AI Assistant
Document Details
Subject
Advanced Placement