Java Software Solutions for AP computer science 3rd Edition Loftus download
Java Software Solutions for AP computer science 3rd Edition Loftus download
https://ebookname.com/product/java-software-solutions-for-ap-
computer-science-3rd-edition-loftus/
https://ebookname.com/product/computing-handbook-computer-
science-and-software-engineering-3ed-edition-allen-b-tucker/
https://ebookname.com/product/software-engineering-and-testing-
an-introduction-computer-science-1st-edition-b-b-agarwal/
https://ebookname.com/product/computer-organization-and-design-
the-hardware-software-interface-3rd-edition-david-a-patterson/
https://ebookname.com/product/gpu-pro-7-advanced-rendering-
techniques-1st-edition-wolfgang-engel/
Land in Conflict Managing and Resolving Land Use
Disputes 1st Edition Sean Nolon
https://ebookname.com/product/land-in-conflict-managing-and-
resolving-land-use-disputes-1st-edition-sean-nolon/
https://ebookname.com/product/lithium-compounds-in-organic-
synthesis-from-fundamentals-to-applications-1st-edition-luisi-
renzo-ed/
https://ebookname.com/product/the-digital-god-how-technology-
will-reshape-spirituality-1st-edition-william-indick/
https://ebookname.com/product/joseph-beuys-1st-edition-claudia-
mesch/
https://ebookname.com/product/manual-of-traumatic-brain-injury-
management-1st-edition-felise-s-zollman/
The Christians as the Romans Saw Them Second Edition
Robert Lewis Wilken
https://ebookname.com/product/the-christians-as-the-romans-saw-
them-second-edition-robert-lewis-wilken/
J ava 3rd Edition
S O F T WA R E S O L U T I O N 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 product.
This page intentionally left blank
J ava 3rd Edition
S O F T WA R E S O L U T I O N S
™
Addison-Wesley
Boston Columbus Indianapolis New York San Francisco Upper Saddle River
Amsterdam Cape Town Dubai London Madrid Milan Munich Paris Montreal Toronto
Delhi Mexico City Sao Paulo Sydney Hong Kong Seoul Singapore Taipei Tokyo
*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 product.
Editor in Chief: Michael Hirsch
Editorial Assistant: Stephanie Sellinger
Marketing Coordinator: Kathryn Ferranti
Managing Editor: Jeffrey Holcomb
Production Project Manager: Heather McNally
Senior Manufacturing Buyer: Carol Melville
Art Director: Linda Knowles
Cover Designer: Joyce Cosentino Wells
Text Designer: Jerilyn Bockorick, Nesbitt Graphics, Inc.
Cover Art: Michael Shivers / Alamy
Full-Service Project Management: Rose Kernan, Nesbitt Graphics, Inc.
Composition and Art: Nesbitt Graphics, Inc.
Credits and acknowledgments borrowed from other sources and reproduced, with permission, in this textbook appear on appropriate
page within text. Many of the designations by manufacturers and seller to distinguish their products are claimed as trademarks. Where
those designations appear in this book, and the publisher was aware of a trademark claim, the designations have been printed in initial
caps or all caps.
Microsoft® and Windows® are registered trademarks of the Microsoft Corporation in the U.S.A. and other countries. Screen shots and
icons reprinted with permission from the Microsoft Corporation. This book is not sponsored or endorsed by or affiliated with the
Microsoft Corporation.
The programs and applications presented in this book have been included for their instructional value. They have been tested with care,
but are not guaranteed for any particular purpose. The publisher does not offer any warranties or representations, nor does it accept
any liabilities with respect to the programs or applications.
Copyright © 2011, 2007, 2004 Pearson Education, Inc., publishing as Addison-Wesley, 501 Boylston Street, Suite 900, Boston,
Massachusetts 02116. All rights reserved. Manufactured in the United States of America. This publication is protected by Copyright,
and permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval system, or transmis-
sion in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. To obtain permission(s) to use material
from this work, please submit a written request to Pearson Education, Inc., Permissions Department, 501 Boylston Street, Suite 900,
Boston, Massachusetts 02116.
1 2 3 4 5 6 7 8 9 10--CRK--14 13 12 11 10
*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 product.
To Sharon, Justin, Kayla, Nathan, and Samantha Lewis
—J.L.
—W.L.
—C.C.
This page intentionally left blank
Preface
Welcome to Java™ Software Solutions for AP* Computer Science. This
Advanced Placement* book matches both the AP* Computer Science topic
outline and Java subset set forth by the College Board.
Chapter Breakdown
Chapter 1 (Computer Systems) introduces computer systems in general,
including basic architecture and hardware, networking, programming, and
language translation. Java is introduced in this chapter, and the basics of pro-
gram development are discussed. This chapter contains broad introductory
material that can be covered while AP* students become familiar with their
development environment.
Chapter 2 (Objects and Primitive Data) establishes the concept of objects
and how they can be used. Many predefined classes from the Java standard
library are explored and used. Enumerated types, primitive types, operators,
and expressions are also explored.
Chapter 3 (Program Statements) covers most of the fundamental state-
ments including conditionals, loops, and iterators. Some additional operators
are introduced at this point as well. Establishing key statements at this point
allows the classes of the next chapter to be fully functional and realistic.
Chapter 4 (Writing Classes) explores issues related to writing classes and
methods. Topics include instance data, visibility, scope, method parameters,
and return types. Method overloading is covered as well. Some of the more
involved topics are deferred to or revisited in Chapter 5. The key to Chapter
4 is the many fully implemented, realistic classes that are presented as exam-
ples of class design.
Chapter 5 (Enhancing Classes) covers additional issues related to class
design and revisits topics that need further exploration. Object references are
revisited and carefully explored, and their impact on parameter passing is
discussed. Exceptions, interfaces, and their effect on design are also covered.
Finally, guidelines on designing classes, as well as testing, are given.
Chapter 6 (Arrays) contains extensive coverage of arrays and array pro-
cessing. Topics include multidimensional arrays, searching, and sorting.
The ArrayList class is explored as well, and generic types are introduced
here.
x PR EFA C E
Supplements
AP* students are welcome to visit www.pearsonhighered.com/cssupport
(author: Lewis/Loftus/Cocking) for the following resources:
■ Source Code to all program examples in the text.
■ Case Study section for most chapters linking the concepts covered in
that chapter with the official AP* case study.
The following supplements are available online for qualified AP* teachers
only, at www.pearsonhighered.com/irc. Teachers may obtain a code to access
the supplements below from their Pearson sales representative. If you need
help finding this material, contact your Pearson sales representative. You can
find your rep in the “Find your sales rep” section atwww.pearsonschool.com.
■ Lesson Plans with Pacing Guide.
■ Solutions to all end-of-chapter exercises and programming projects.
■ PowerPoint slides.
■ Test Bank with powerful test generator software, includes a wealth of
free response, multiple choice, and true/false questions.
■ Source Code to all program examples in the text.
V. STANDARD ALGORITHMS
Standard algorithms serve as examples of good solutions to standard problems. Many are inter-
twined with standard data structures. These algorithms provide examples for analysis of program effi-
ciency.
A. Operations on data structures previously listed
1. Traversals Sections 6.0, 6.1, 6.7
2. Insertions Sections 6.0, 6.1, 6.7
3. Deletions Sections 6.0, 6.1, 6.7
B. Searching
1. Sequential Section 6.2
2. Binary Section 6.2
C. Sorting
1. Selection Section 6.3
2. Insertion Section 6.3
3. Mergesort Section 8.3
An awareness of the ethical and social implications of computing systems is necessary for the study
of computer science. These topics need not be covered in detail but should be considered through-
out the course.
A. System reliability Appendix F
B. Privacy Appendix F
C. Legal issues and intellectual property Appendix F
D. Social and ethical ramifications of computer use Appendix F
Acknowledgments
We are most grateful to the AP* teachers and AP* students from around the
world who have provided their feedback on the previous edition of this book.
We are pleased to see the depth of the faculty’s concern for their AP* students
and the AP* students’ thirst for knowledge. Your comments and questions
are always welcome.
Michael Hirsch and Stephanie Sellinger, our editors at Addison-Wesley,
went above and beyond the call of duty to ensure that the book met the high-
est quality standards. Their support and enthusiasm are greatly appreciated.
We are also grateful to Andrea Sheehan and Courtney Marsh with Pearson
School for making sure that AP* teachers understand the pedagogical advan-
tages of this text. The devotion that the Addison-Wesley and Pearson folks
show to their books is evident in the high-quality results.
xiv PR EFA C E
The production team for this edition is a group of gifted and hard-working
people—miracle workers all. Thanks go to Heather McNally, Joyce
Cosentino Wells (for the wonderful cover), and Rose Kernan and the rest of
the Nesbitt Graphics group. The quality of the book is due largely to their
personal attention, and it is greatly appreciated.
Special thanks also go to the reviewers of this text over the last few edi-
tions, as well as the many other instructors and friends who have provided
valuable feedback.
They include Neil Ascione—Wayne Valley High School, NJ; Brian Ellis—
Manheim Township School District, PA; Kathy Gilbert—Cary-Grove High
School, IL; Gregory King—Dublin Coffman High School, OH; Richard
Lamb—Cranbrook High School, MI; Deepa Muralidhar—Northview High
School, GA; Kim Murphy—Weber High School, UT; G. Lynne Ryan—North
Crowley High School, TXJenka Guevara, American School Foundation,
Mexico City; Leigh Ann Sudol, Fox Lane High School/New York University,
NY; Kathleen Weaver, Hillcrest High School, Dallas, TX; John E. Hanna,
Teaneck High School, NJ; Brian G. Scarbeau, Lake Highland Preparatory
School, FL; Frances Caruso Wolanczyk, Fieldston School, NY; Mark
Hanington, Punahou School, Honolulu, HI; Rose M. Hoffman, Catholic
Memorial High School, Waukesha, WI; Kathleen Larson, Kingston High
School, Kingston, NY; Bob Beck, Villanova University; Paul Gormley,
Villanova University; Cathy Helwig, Villanova University; Dan Joyce,
Villanova University; Najib Nadi, Villanova University; Beth Taddei,
Villanova University; Barbara Zimmerman, Villanova University; John
Simms, Marquette University; Marian Manyo, Marquette University.
Most importantly, we thank our families for their support during the busy
process of writing, not to mention the other times.
Feature Walkthrough
Key Concepts. Throughout the
2.1 Computer Processing 63
text, the Key Concept boxes high-
disk. When you instruct the computer to execute your program, a
light fundamental ideas and
KEY C ON C EPT
copy of the program is brought in from secondary memory and
stored in main memory. The CPU reads the individual program
The CPU reads the program important guidelines. These con-
instructions from main memory,
instructions from main memory. The CPU then executes the instruc-
tions one at a time until the program ends. The data that the instruc-
executing them one at a time
until the program ends. cepts are summarized at the end
tions use, such as two numbers that will be added together, are also
stored in main memory.
of each chapter.
The process of executing a program is fundamental to the operation of a
computer. All computer systems basically work in the same way.
O U T P U T
xv
xvi F EAT U R E WALKTHRO UG H
Graphics
cal user interfaces is discussed in K EY C ON C EPT
Graphics play a crucial role in computer systems. Throughout
this book we explore various aspects of graphics and discuss
one or two sections at the end of Graphical data is represented by
dividing it into many small pieces how they are accomplished. In fact, the last one or two sec-
called pixels. tions of each chapter are devoted to graphics topics. We refer
each chapter that we collectively to this as the Graphics Track through the book. These sections
can be skipped without losing continuity through the rest of the text, incor-
refer to as the Graphics Track. This porated into the regular flow of the chapters, or explored as a group.
A picture, like all other information stored on a computer, must be digi-
material can be skipped without tized by breaking the information into pieces and representing those pieces as
numbers. In the case of pictures, we break the picture into pixels (picture ele-
loss of continuity, or focused on ments). A pixel is a tiny region that represents a very small piece of the pic-
ture. The complete picture is stored by storing the color of each individual
specifically as desired. The mate- pixel.
rial in any Graphics Track section A digitized picture can be reproduced when needed by reassembling its
pixels. The more pixels used to represent a picture, the more realistic it looks
relates to the main topics of the when it is reproduced. The number of pixels used to represent a picture is
called the picture resolution. The number of pixels that can be displayed by
chapter in which it is found. a monitor is called the monitor resolution. A black and white picture can be
stored by representing each pixel using a single bit. If the bit is 0, that pixel
Graphics Track sections are indi- is white; if the bit is 1, it is black. Figure 2.8 shows a black and white picture
that has been stored digitally and an enlargement of a portion of that picture,
cated by a light blue border on which shows the individual pixels.
Graphics play a crucial role in computer systems. Throughout this book
the edge of the page. we explore various aspects of graphics and discuss how they are accom-
plished. In fact, the last one or two sections of each chapter are devoted to
graphics topics. We refer to this as the Graphics Track through the book.
F EAT U RE WALK T H RO U G H xvii
Preface vii
xix
xx CONTENTS
1.5 Graphics 38
Coordinate Systems 38
Representing Color 40
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebookname.com