Java Programming 5th Edition Joyce Farrell download
Java Programming 5th Edition Joyce Farrell download
download
https://ebookname.com/product/java-programming-5th-edition-joyce-
farrell/
https://ebookname.com/product/programming-logic-and-design-
comprehensive-6th-edition-joyce-farrell/
https://ebookname.com/product/object-oriented-programming-using-
c-fourth-edition-joyce-farrell/
https://ebookname.com/product/just-enough-programming-logic-and-
design-1st-edition-joyce-farrell/
https://ebookname.com/product/ethics-volume-iii-moral-freedom-
nicolai-hartmann/
Modern Syntax A Coursebook 1st Edition Andrew Carnie
https://ebookname.com/product/modern-syntax-a-coursebook-1st-
edition-andrew-carnie/
https://ebookname.com/product/lifestyle-medicine-second-edition-
james-m-rippe/
https://ebookname.com/product/test-signal-generation-for-service-
diagnosis-based-on-local-structure-graphs-1st-edition-michael-
ungermann/
https://ebookname.com/product/elizabeth-the-golden-age-first-
edition-tasha-alexander/
https://ebookname.com/product/pelvic-power-mindbody-exercises-
for-strength-flexibility-posture-and-balance-for-men-and-
women-1st-edition-eric-franklin/
Management 4th Edition David Boddy
https://ebookname.com/product/management-4th-edition-david-boddy/
Java Programming
Fifth Edition
Joyce Farrell
Australia • Brazil • Japan • Korea • Mexico • Singapore • Spain • United Kingdom • United States
Java Programming, Fifth Edition © 2010 Course Technology, Cengage Learning
Joyce Farrell
ALL RIGHTS RESERVED. No part of this work covered by the copyright herein
Executive Editor: Marie Lee may be reproduced, transmitted, stored, or used in any form or by any means—
graphic, electronic, or mechanical, including but not limited to photocopying,
Acquisitions Editor: Amy Jollymore
recording, scanning, digitizing, taping, Web distribution, information networks, or
Managing Editor: Tricia Coia information storage and retrieval systems, except as permitted under Section
Development Editor: Dan Seiter 107 or 108 of the 1976 United States Copyright Act—without the prior written
permission of the publisher.
Editorial Assistant:
Julia Leroux-Lindsey
For product information and technology assistance, contact us at
Marketing Manager: Bryant Chrzan Cengage Learning Customer & Sales Support, 1-800-354-9706
Content Project Manager: For permission to use material from this text or product,
Heather Furrow submit all requests online at www.cengage.com/permissions
Art Director: Marissa Falco Further permissions questions can be e-mailed to
permissionrequest@cengage.com
Cover Designer: Bruce Bond
Cover Photo: TBD
Microsoft® is a registered trademark of the Microsoft Corporation.
Manufacturing Coordinator:
Julio Esperas ISBN-13: 978-0-3245-9951-0
Printed in Canada
1 2 3 4 5 6 7 12 11 10 09 08
BRIEF CONTENTS
PREFACE xix
READ THIS BEFORE YOU BEGIN xxv
iii
This page intentionally left blank
CONTENTS
PREFACE xix
READ THIS BEFORE YOU BEGIN xxv
v
CONTENTS
DEBUGGING EXERCISES 39
GAME ZONE 39
TOUGH QUESTIONS 40
UP FOR DISCUSSION 41
vi
CONTENTS
vii
CONTENTS
viii
CONTENTS
YOU DO IT 213
Using an if...else 213
Creating an Event Class to Use in a Decision-Making Application 215
Writing an Application that Uses the Event class 216
Using the switch Statement 218
DON’T DO IT 219
KEY TERMS 220
CHAPTER SUMMARY 221
REVIEW QUESTIONS 221
EXERCISES 224
DEBUGGING EXERCISES 229
GAME ZONE 229
TOUGH QUESTIONS 231
UP FOR DISCUSSION 232
ix
CONTENTS
x
CONTENTS
xi
CONTENTS
YOU DO IT 391
Creating a Superclass and an Application to Use It 391
Creating a Subclass and an Application to Use It 393
Creating a Subclass Method That Overrides a Superclass Method 395
Understanding the Role of Constructors in Inheritance 397
Inheritance When the Superclass Requires Constructor Arguments 398
Accessing an Overridden Superclass Method from Within a Subclass 401
DON’T DO IT 402
KEY TERMS 402
CHAPTER SUMMARY 403
REVIEW QUESTIONS 404
EXERCISES 407
DEBUGGING EXERCISES 410
GAME ZONE 410
TOUGH QUESTIONS 411
UP FOR DISCUSSION 412
xii
CONTENTS
xiii
CONTENTS
xiv
CONTENTS
xv
CONTENTS
xvi
CONTENTS
xvii
CONTENTS
xviii
PREFACE
Java Programming, Fifth Edition provides the beginning programmer with a guide to developing applica-
tions using the Java programming language. Java is popular among professional programmers because it
can be used to build visually interesting graphical user interface (GUI) and Web-based applications. Java
also provides an excellent environment for the beginning programmer—a student quickly can build use-
ful programs while learning the basics of structured and object-oriented programming techniques.
This textbook assumes that you have little or no programming experience. This book provides a solid
background in good object-oriented programming techniques and introduces object-oriented terminology
using clear, familiar language. The writing is nontechnical and emphasizes good programming practices.
The examples are business examples; they do not assume a mathematical background beyond high-school
business math. In addition, the examples illustrate only one or two major points; they do not contain so
many features that you become lost following irrelevant and extraneous details. The explanations in this
textbook are written clearly in straightforward sentences so that native and non-native English speakers
alike can master the programming concepts. Complete, working code examples appear frequently in each
chapter; these examples help the student make the transition from the theoretical to the practical. The
code presented in each chapter is also provided on disk, so that students can easily run the programs and
experiment with changes to them.
xix
PREFACE
also provides students with a successful experience in the language; finishing the examples provides them
with models for their own creations.
The student using Java Programming, Fifth Edition builds applications from the bottom up, rather than
starting with existing objects. This facilitates a deeper understanding of the concepts used in object-
oriented programming, and engenders appreciation for the existing objects students use as their knowl-
edge of the language advances. When students complete this book, they will know how to modify and
create simple Java programs and will have the tools to create more complex examples. They also will
have a fundamental knowledge of object-oriented programming, which will serve them well in advanced
Java courses or in studying other object-oriented languages such as C++, C#, and Visual Basic.
FEATURES
Java Programming, Fifth Edition is a superior textbook because it also includes the following features:
» Objectives: Each chapter begins with a list of objectives so you know the topics that will be present-
ed in the chapter. In addition to providing a quick reference to topics covered, this feature provides a
useful study aid.
» Notes: These highlighted tips provide additional information—for example, an alternative method
of performing a procedure, another term for a concept, background information on a technique, or a
common error to avoid.
» Figures: Each chapter contains many figures. Code figures are most frequently 25 lines or less, illus-
trating one concept at a time. Frequently placed screen shots show exactly how program output
appears.
NEW! » Callouts in more figures: Callouts have been added to many figures to help students focus on the
points emphasized in the text. Some icons contain the words “Don’t Do It” to emphasize when an
example illustrates a practice not to emulate.
» Color: The code figures in each chapter contain all Java keywords in brown. This helps students
identify keywords more easily, distinguishing them from programmer-selected names.
» Files: The Student Disk holds more than 180 files that contain the code presented in the figures in
each chapter. Students can run the code for themselves, view the output, and make changes to the
code to observe the effects.
NEW! » Two Truths and a Lie: A new quiz reviews each chapter section, with answers provided. This quiz
contains three statements from the preceding section of text—two statements are true and one is
false. Over the years, students have requested answers to problems, but we have hesitated to distrib-
ute them in case instructors want to use problems as assignments or test questions. These true-false
mini-quizzes provide students with immediate feedback as they read, without “giving away”
answers to the existing multiple-choice and programming problem questions.
» You Do It: In each chapter, step-by-step exercises help the student create multiple working pro-
grams that emphasize the logic a programmer uses in choosing statements to include. This section
provides a means for students to achieve success on their own—even those in online or distance
learning classes.
NEW! » Don’t Do It: This section at the end of each chapter summarizes common mistakes and pitfalls that
plague new programmers while learning the current topic.
xx
PREFACE
» Key Terms: Each chapter includes a list of newly introduced vocabulary, shown in the order of appear-
ance in the text. The list of key terms provides a mini-review of the major concepts in the chapter.
» Summaries: Following each chapter is a summary that recaps the programming concepts and tech-
niques covered in the chapter. This feature helps students check their understanding of the main
points in each chapter.
» Review Questions: Each chapter includes 20 multiple-choice questions that serve as a review of
chapter topics.
» Exercises: Each chapter concludes with meaningful programming exercises that provide additional
practice of the skills and concepts learned in the chapter. These exercises vary in difficulty and are
designed to allow exploration of logical programming concepts.
» Game Zone: Each chapter provides one or more exercises in which the student creates interactive
games using the programming techniques learned up to that point; 70 game programs are suggested
in the book. The games are fun to create and play; writing them motivates students to master the
necessary programming techniques. Students might exchange completed game programs with each
other, suggesting improvements and discovering alternate ways to accomplish tasks.
» Tough Questions: Each chapter includes two or more fairly difficult, and often open-ended, questions NEW!
that are typical of what an applicant might encounter in a technical job interview. Some questions involve
coding; others might involve research.
» Up for Discussion: Each chapter concludes with a few thought-provoking questions concerning
programming in general or Java in particular. The questions can be used to start classroom or online
discussions, or to develop and encourage research, writing, and language skills.
» Glossary: This edition includes a glossary that contains definitions for all key terms in the book, NEW!
presented in alphabetical order.
» Appendix on javadoc: This edition includes a new appendix on creating javadoc comments. NEW!
» Other pedagogical improvements: This edition introduces the following pedagogical improvements: NEW!
» The Scanner class is introduced in Chapter 2 to facilitate user keyboard entry in programs.
» Programming examples provide earlier and more consistent use of named constants.
» Clearer distinction between troublesome concepts is provided—for example, argument vs. parameter
and static vs. nonstatic.
» The String chapter focuses on StringBuilder instead of StringBuffer because StringBuilder
is more efficient. However, it is emphasized that the two classes are used in exactly the same way.
» The GUI chapters have been completely rewritten and moved later in the book, which makes it
easier for instructors who want to cover the concepts of inheritance and polymorphism first. Similarly,
applet coverage has been removed from the GUI chapters, which makes it easier for instructors who
want to cover GUI topics first.
» Applets have been moved to the last chapter in the book, reflecting their diminished popularity as
a business tool.
» Quality: Every program example in the book, as well as every exercise and game solution, was
tested by the author and then tested again by a Quality Assurance team using Java Standard
Edition (SE) 6, the most recent version available. (The external version number used by Sun
Microsystems is 6.0; the internal version number is 1.6.0. For more information on the features
of the JDK, visit http://java.sun.com.)
xxi
PREFACE
» CD-ROM included with book: The CD that comes with this book includes the following items:
» Sun Microsystems Java SE 6, the Java language, compiler, and runtime environment
» The jGRASP integrated development environment for Java
» Code files for all Java program examples contained in the text
TEACHING TOOLS
The following supplemental materials are available when this book is used in a classroom setting. All of
the teaching tools available with this book are provided to the instructor on a single CD.
» Electronic Instructor’s Manual: The Instructor’s Manual that accompanies this textbook includes
additional instructional material to assist in class preparation, including items such as Sample Syllabi,
Chapter Outlines, Technical Notes, Lecture Notes, Quick Quizzes, Teaching Tips, Discussion Topics,
and Key Terms.
» ExamView®: This textbook is accompanied by ExamView, a powerful testing software package
that allows instructors to create and administer printed, computer (LAN-based), and Internet-
based exams. ExamView includes hundreds of questions that correspond to the topics covered in
this text, enabling students to generate detailed study guides that include page references for further
review. The computer-based and Internet testing components allow students to take exams at their
computers, and they save the instructor time by grading each exam automatically.
» PowerPoint Presentations: This book comes with Microsoft PowerPoint slides for each chapter.
These are included as a teaching aid for classroom presentation, to make available to students on the
network for chapter review, or to be printed for classroom distribution. Instructors can add their
own slides for additional topics they introduce to the class.
» Solution Files: Solutions to “You Do It” exercises and all end-of-chapter exercises are provided
on the Instructor Resources CD and on the Course Technology Web site at www.course.com. The
solutions are password protected.
Annotated solutions are provided for the multiple-choice Review Questions. For example, if students
are likely to debate answer choices, or not understand the choice deemed to be the correct one,
a rationale is provided.
» Distance Learning: Course Technology is proud to present online test banks in WebCT and
Blackboard to provide the most complete and dynamic learning experience possible. Instructors
are encouraged to make the most of the course, both online and offline. For more information on
how to access the online test bank, contact your local Course Technology sales representative.
xxii
PREFACE
ACKNOWLEDGEMENTS
I would like to thank all of the people who helped to make this book a reality, especially Dan Seiter,
Development Editor. Dan’s suggestions and attention to detail made this a superior book, and his sense
of humor made writing it practically painless.
Thanks also to Tricia Coia, Managing Editor; and Heather Furrow, Content Project Manager. I am lucky
to work with Tricia and Heather; they are dedicated to producing quality instructional materials.
Thanks to Serge Palladino, John Freitas, and Chris Scriver of the Quality Assurance Department.
Thank you to Dick Grant of Seminole Community College, Sanford, Florida. He provided important
technical and pedagogical suggestions based on his classroom use of this book. He possesses the rare
combination of excellent teacher and programmer, and he made this book more accurate and more
useful to students.
I am also grateful to the many other reviewers who provided comments and encouragement during this
book’s development, including Karlyn Barilovits, Kaplan University; Kay Chen, Bucks County Community
College; Roman Erenshteyn, Goldey-Beacom College; Jeff Hedrington, University of Phoenix-Online; and
Aaron Jagers, Louisiana Technical College.
Thanks, too, to my husband, Geoff, who supports me every step of the way. Finally, this book is dedicated
to our lifelong friends, George and Mary Profeta.
Joyce Farrell
xxiii
This page intentionally left blank
Exploring the Variety of Random
Documents with Different Content
Nachbarn und Nachbarinnen, sowie den Gästen, welche die Gargotte
seines Schwiegervaters besuchten, Mittel gegen das Fieber und
andere unangenehme Übel zu verkaufen.
Allmählich verwandelte sich das Wohngemach der kleinen Familie in
ein schwarzangeräuchertes chemisches Laboratorium; mit wahrer
Leidenschaft warf sich Stefano Vinacche, obgleich er bis an sein
Ende weder lesen noch schreiben lernte, auf das Studium der Simpla
und der Mineralien.
Eine gewaltige Veränderung ging mit dem seltsamen Menschen vor;
— nicht mehr war er der vagabondierende Abenteurer, der das Glück
seines Lebens auf den Landstraßen, in den Gassen suchte. Tag und
Nacht schritt er grübelnd einher, das Haupt zur Brust gesenkt, die
Arme über der Brust gekreuzt. Wer konnte sagen, was er suchte?
Eine fast ebenso überraschende Veränderung kam über das junge
Weib Vinacches. Die frühere Mätresse des Herzogs von Chaulnes
verehrte den ihr aufgedrungenen Mann auf den Knien, sie war die
treuste, liebendste Gattin geworden, und ist es über den Tod
Stefanos hinaus geblieben.
S i e konnte lesen, s i e konnte schreiben: —wie viele alte vergilbte
Bouquins hat sie dem suchenden Forscher, in stillen Nächten,
während sie ihr Kind wiegte, vorgelesen!
Der Vater Bullot hatte nicht mehr Ursache, sich über das wilde,
unbändige Gebaren seiner Tochter zu beklagen. Die eigentümliche
Gewalt, welche Stefano Vinacche späterhin über die schärfsten,
klarsten Geister hatte, trat auch jetzt in der engeren Sphäre schon
bedeutend hervor. Papa Claude, Margot die Picarde, Gratien Le
Poudrier der Rabulist, alle Nachbaren und alle Nachbarinnen beugten
sich dem schwarzen, funkelnden Auge Stefanos. Der Stein war ins
Wasser gefallen, und die Wellenringe liefen in immer weitern Kreisen
fort; — weit, weit über die Gasse Quincampoix hinaus verbreitete
sich der Ruf Stefano Vinacches!
Unterdessen schlug man sich in Deutschland, Flandern, Spanien,
Italien und auf der See. In Deutschland verbrannte Melac
Heidelberg, und der Feldmarschallleutnant von Hettersdorf, der „die
poltronnerie seines Herzens mit großen Peruquen und bebremten
Kleidern zu bedecken pflegte“, — Hettersdorf, der elende
Kommandant der unglücklichen Stadt, wurde auf einem
Schinderkarren durch die Armee des Prinzen Ludwig von Baden
geführt, nachdem ihm der Degen vom Henker zerbrochen worden
war. Aus Flandern schickte der Marschall von Luxemburg durch
d’Artagnan die Nachricht vom Sieg bei Neerwinden. Roses in
Katalonien wurde erobert. Zu Versailles, zu Paris in der Kirche
unserer lieben Frau sang man Te Deum laudamus; aber im
Bischoftum Limoges starben gegen zehntausend Menschen Hungers.
Zu Lyon wie zu Rouen fiel das Volk in den Gassen wie Fliegen, und
ihrer viel fand man, welche den Mund voll Gras hatten, ihr elendes
Leben damit zu fristen.
Stefano Vinacche, nach einer Reise in die Bretagne, verließ die Gasse
Quincampoix und das Haus seines Schwiegervaters und zog in die
Gasse Bourg l’Abbé. Strahlend brach die Glückssonne Stefanos durch
die Wolken. Fünf Monate war er in der Bretagne gewesen, und
niemand hat jemals erfahren, was er dort getrieben, — gesucht, —
gefunden hat! Zu Fuß zog er aus, in einer zweispännigen Karosse
kehrte er zurück. Zwei Lakaien und ein Kammerdiener bedienten ihn
in der Straße Bourg l’Abbé, wohin er aus der Gasse Quincampoix
zog. Von neuem errichtete er in seiner jetzigen Wohnung seine
chemischen Feuerherde, von neuem braute er seine Rezepte, und
das Gerücht ging aus, Monsieur Etienne Vinacche suche den Stein
der Weisen, und es sei Hoffnung vorhanden, daß er denselben
binnen kurzem finden werde; und wieder tritt dem Erzähler der alte
Gönner des unbegreiflichen Mannes, der Herzog von Chaulnes,
entgegen, welcher ihm zum Ankauf von Kohlen, Retorten und
dergleichen Apparaten zweitausend Taler gibt.
Im Jahr der Gnade Eintausendsiebenhundert war das große
Geheimnis gefunden; — Stefano Vinacche hatte das
Projektionspulver hergestellt, Etienne Vinacche machte —
Gold!
In demselben Jahre Eintausendsiebenhundert kaufte M o n s i e u r
d e V i n a c c h e aus dem Inventar von Monsieur, dem Bruder des
Königs, für sechzigtausend Livres Diamanten.
III.
Glück und Glanz.
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