Instant Download Java Programming Joyce Farrell PDF All Chapter
Instant Download Java Programming Joyce Farrell PDF All Chapter
com
https://textbookfull.com/product/java-
programming-joyce-farrell/
textbookfull
More products digital (pdf, epub, mobi) instant
download maybe you interests ...
https://textbookfull.com/product/java-programming-joyce-
farrell-2/
https://textbookfull.com/product/practical-numerical-c-
programming-1st-edition-philip-joyce/
https://textbookfull.com/product/programming-in-java-sachin-
malhotra/
https://textbookfull.com/product/murach-s-java-programming-joel-
murach/
Practical Numerical C Programming: Finance,
Engineering, and Physics Applications Philip Joyce
https://textbookfull.com/product/practical-numerical-c-
programming-finance-engineering-and-physics-applications-philip-
joyce/
https://textbookfull.com/product/learning-java-an-introduction-
to-real-world-programming-with-java-marc-loy/
https://textbookfull.com/product/learning-java-beginning-
programming-with-java-for-dummies-first-edition-john-bach/
https://textbookfull.com/product/java-network-programming-fourth-
edition-harold-elliotte/
https://textbookfull.com/product/computer-graphics-programming-
in-opengl-with-java-gordon/
TM
JAVA PROGRAMMING
Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
EIGHTH EDITION
TM
JAVA PROGRAMMING
JOYCE FARRELL
Australia • Brazil • Japan • Korea • Mexico • Singapore • Spain • United Kingdom • United States
Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
This is an electronic version of the print textbook. Due to electronic rights restrictions, some third party content may be suppressed. Editorial
review has deemed that any suppressed content does not materially affect the overall learning experience. The publisher reserves the right to
remove content from this title at any time if subsequent rights restrictions require it. For valuable information on pricing, previous
editions, changes to current editions, and alternate formats, please visit www.cengage.com/highered to search by
ISBN#, author, title, or keyword for materials in your areas of interest.
Important Notice: Media content referenced within the product description or the product text may not be available in the eBook version.
Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Java Programming, © 2016, 2014, 2012 Cengage Learning
Eighth Edition WCN: 02-200-203
Joyce Farrell
ALL RIGHTS RESERVED. No part of this work covered by the copyright
Product Director: herein may be reproduced, transmitted, stored, or used in any form or
Kathleen McMahon by any means graphic, electronic, or mechanical, including but not
Senior Content Developer: limited to photocopying, recording, scanning, digitizing, taping, Web
Alyssa Pratt distribution, information networks, or information storage and
retrieval systems, except as permitted under Section 107 or 108 of the
Development Editor: Dan Seiter
1976 United States Copyright Act, without the prior written
Marketing Manager: Eric LaScola permission of the publisher.
Manufacturing Planner:
Julio Esperas
For product information and technology assistance, contact us at
Art Director: Jack Pendleton Cengage Learning Customer & Sales Support, 1-800-354-9706
Production Management,
For permission to use material from this text or product,
Copyediting, Composition,
Proofreading, and Indexing: submit all requests online at www.cengage.com/permissions.
Integra Software Services Pvt. Ltd. Further permissions questions can be emailed to
Cover Photo: [email protected].
©Maram/Shutterstock.com
Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Brief Contents
v
Preface . . . . . . . . . . . . . . . . . . . . . . xxi
CHAPTER 1 Creating Java Programs . . . . . . . . . . . . . . . . 1
CHAPTER 2 Using Data . . . . . . . . . . . . . . . . . . . . . 53
CHAPTER 3 Using Methods, Classes, and Objects . . . . . . . 119
CHAPTER 4 More Object Concepts . . . . . . . . . . . . . . . 183
CHAPTER 5 Making Decisions . . . . . . . . . . . . . . . . . 245
CHAPTER 6 Looping . . . . . . . . . . . . . . . . . . . . . 301
CHAPTER 7 Characters, Strings, and the StringBuilder . . . 353
CHAPTER 8 Arrays . . . . . . . . . . . . . . . . . . . . . . 393
CHAPTER 9 Advanced Array Concepts . . . . . . . . . . . . . 439
CHAPTER 10 Introduction to Inheritance . . . . . . . . . . . . . 491
CHAPTER 11 Advanced Inheritance Concepts . . . . . . . . . . 537
CHAPTER 12 Exception Handling . . . . . . . . . . . . . . . . 593
CHAPTER 13 File Input and Output . . . . . . . . . . . . . . . 665
CHAPTER 14 Introduction to Swing Components . . . . . . . . 729
CHAPTER 15 Advanced GUI Topics . . . . . . . . . . . . . . . 791
CHAPTER 16 Graphics . . . . . . . . . . . . . . . . . . . . . 861
APPENDIX A Working with the Java Platform . . . . . . . . . . . 919
APPENDIX B Data Representation . . . . . . . . . . . . . . . 925
APPENDIX C Formatting Output . . . . . . . . . . . . . . . . 931
APPENDIX D Generating Random Numbers . . . . . . . . . . . 941
APPENDIX E Javadoc . . . . . . . . . . . . . . . . . . . . . 949
Glossary . . . . . . . . . . . . . . . . . . . . 957
Index . . . . . . . . . . . . . . . . . . . . . . 979
Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Contents
vi
Preface . . . . . . . . . . . . . . . . . . xxi
Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Chapter Summary . . . . . . . . . . . . . . . . . . . . . . 45
Review Questions . . . . . . . . . . . . . . . . . . . . . . 46
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . 48
Programming Exercises . . . . . . . . . . . . . . . . . . 48
Debugging Exercises . . . . . . . . . . . . . . . . . . . 50 vii
Game Zone . . . . . . . . . . . . . . . . . . . . . . . . 50
Case Problems . . . . . . . . . . . . . . . . . . . . . . 51
Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
CONTENTS
Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
CHAPT ER 4 More Object Concepts . . . . . . . . . . . 183
Understanding Blocks and Scope . . . . . . . . . . . . . . 184
Overloading a Method . . . . . . . . . . . . . . . . . . . 192
Automatic Type Promotion in Method Calls . . . . . . . . . 194
Learning About Ambiguity . . . . . . . . . . . . . . . . . 199 ix
Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
CONTENTS
Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Altering a Definite Loop’s Control Variable . . . . . . . . . . 307
Writing an Indefinite while Loop . . . . . . . . . . . . . 308
Validating Data . . . . . . . . . . . . . . . . . . . . . 310
Using Shortcut Arithmetic Operators . . . . . . . . . . . . . 314
Creating a for Loop . . . . . . . . . . . . . . . . . . . 319 xi
Unconventional for Loops . . . . . . . . . . . . . . . . 320
Learning How and When to Use a do…while Loop . . . . . . 325
Learning About Nested Loops . . . . . . . . . . . . . . . . 328
Improving Loop Performance . . . . . . . . . . . . . . . . 333
Avoiding Unnecessary Operations . . . . . . . . . . . . . 333
Considering the Order of Evaluation of Short-Circuit
Operators . . . . . . . . . . . . . . . . . . . . . . 334
Comparing to Zero . . . . . . . . . . . . . . . . . . . 334
Employing Loop Fusion . . . . . . . . . . . . . . . . . . 336
Using Prefix Incrementing Rather than Postfix
Incrementing . . . . . . . . . . . . . . . . . . . . . 337
A Final Note on Improving Loop Performance . . . . . . . . 338
Don’t Do It . . . . . . . . . . . . . . . . . . . . . . . . 342
Key Terms . . . . . . . . . . . . . . . . . . . . . . . . 342
Chapter Summary . . . . . . . . . . . . . . . . . . . . . 344
Review Questions . . . . . . . . . . . . . . . . . . . . . 344
Exercises . . . . . . . . . . . . . . . . . . . . . . . . 347
Programming Exercises . . . . . . . . . . . . . . . . . 347
Debugging Exercises . . . . . . . . . . . . . . . . . . 350
Game Zone . . . . . . . . . . . . . . . . . . . . . . . 350
Case Problems . . . . . . . . . . . . . . . . . . . . . 352
Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
CONTENTS
Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
CHAPT ER 9 Advanced Array Concepts . . . . . . . . . 439
Sorting Array Elements Using the Bubble Sort Algorithm . . . . 440
Using the Bubble Sort Algorithm . . . . . . . . . . . . . . 440
Improving Bubble Sort Efficiency . . . . . . . . . . . . . 442
Sorting Arrays of Objects . . . . . . . . . . . . . . . . . 443 xiii
Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
CONTENTS
Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
CONTENTS
Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Using the JCheckBox, ButtonGroup, and JComboBox
Classes . . . . . . . . . . . . . . . . . . . . . . . . 767
The JCheckBox Class . . . . . . . . . . . . . . . . . 767
The ButtonGroup Class . . . . . . . . . . . . . . . . 771
The JComboBox Class . . . . . . . . . . . . . . . . . 772 xvii
Don’t Do It . . . . . . . . . . . . . . . . . . . . . . . . 780
Key Terms . . . . . . . . . . . . . . . . . . . . . . . . 780
Chapter Summary . . . . . . . . . . . . . . . . . . . . . 781
Review Questions . . . . . . . . . . . . . . . . . . . . . 783
Exercises . . . . . . . . . . . . . . . . . . . . . . . . 785
Programming Exercises . . . . . . . . . . . . . . . . . 785
Debugging Exercises . . . . . . . . . . . . . . . . . . 787
Game Zone . . . . . . . . . . . . . . . . . . . . . . . 787
Case Problems . . . . . . . . . . . . . . . . . . . . . 788
Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
CONTENTS
Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Programming Exercises . . . . . . . . . . . . . . . . . 915
Debugging Exercises . . . . . . . . . . . . . . . . . . 916
Game Zone . . . . . . . . . . . . . . . . . . . . . . . 916
Case Problems . . . . . . . . . . . . . . . . . . . . . 918
xix
APPENDIX A Working with the Java Platform . . . . . . . 919
Learning about the Java SE Development Kit . . . . . . . . . 920
Configuring Windows to Use the JDK . . . . . . . . . . . . . 920
Finding the Command Prompt . . . . . . . . . . . . . . . 921
Command Prompt Anatomy . . . . . . . . . . . . . . . . 921
Changing Directories . . . . . . . . . . . . . . . . . . 921
Setting the class and classpath Variables . . . . . . . 922
Changing a File’s Name . . . . . . . . . . . . . . . . . 922
Compiling and Executing a Java Program . . . . . . . . . . . 923
Key Terms . . . . . . . . . . . . . . . . . . . . . . . . 923
Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
CONTENTS
Glossary . . . . . . . . . . . . . . . . . 957
Index . . . . . . . . . . . . . . . . . . . 979
Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Preface
xxi
Java Programming, Eighth Edition, provides the beginning programmer with a guide to
developing applications 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 can quickly build useful programs while learning the
basics of structured and object-oriented programming techniques.
This textbook assumes that you have little or no programming experience. It provides a solid
background in good object-oriented programming techniques and introduces terminology
using clear, familiar language. The programming 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. Complete, working programs
appear frequently in each chapter; these examples help students make the transition from the
theoretical to the practical. The code presented in each chapter can also be downloaded from
the publisher’s Web site, so students can easily run the programs and experiment with
changes to them.
The student using Java Programming, Eighth 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 knowledge of the language advances. When students complete
this book, they will know how to modify and create simple Java programs, and they 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.
Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
PREFACE Features
Chapters 10, 11, and 12 thoroughly cover inheritance and exception handling. Inheritance is
the object-oriented concept that allows you to develop new objects quickly by adapting the
features of existing objects; exception handling is the object-oriented approach to handling
errors. Both are important concepts in object-oriented design. Chapter 13 provides
information on handling files so you can permanently store and retrieve program output.
xxii
Chapters 14, 15, and 16 introduce GUI Swing components (Java’s visually pleasing,
user-friendly widgets), their layout managers, and graphics.
Features
The following features are new for the Eighth Edition:
JAVA 8E: All programs have been tested using Java 8e, the newest edition of Java.
WINDOWS 8.1: All programs have been tested in Windows 8.1, and all screen shots have
been taken in this new environment.
DATE AND TIME CLASSES: This edition provides thorough coverage of the java.time
package, which is new in Java 8e.
ON-SCREEN KEYBOARD: This edition provides instructions for displaying and using an
on-screen keyboard with either a touch screen or a standard screen.
MODERNIZED GRAPHICS OUTPUT: The chapter on graphics (Chapter 16) has been
completely rewritten to focus on Swing component graphics production using the
paintComponent() method.
Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Features
EMPHASIS ON STUDENT RESEARCH: The student frequently is directed to the Java Web
site to investigate classes and methods. Computer languages evolve, and programming
professionals must understand how to find the latest language improvements. This book
encourages independent research.
FIGURES: Each chapter contains many figures. Code figures are most frequently 25 lines
xxiii
or fewer, illustrating one concept at a time. Frequent screen shots show exactly how
program output appears. Callouts appear where needed to emphasize a point.
COLOR: The code figures in each chapter contain all Java keywords in blue. This helps
students identify keywords more easily, distinguishing them from programmer-selected
names.
FILES: More than 200 student files can be downloaded from the publisher’s Web site. Most
files 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. Other
files include debugging exercises that help students improve their programming skills.
TWO TRUTHS & A LIE: A short quiz reviews each chapter section, with answers provided.
This quiz contains three statements based on 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 distribute them in case instructors want to use
problems as assignments or test questions. These true–false quizzes provide students with
immediate feedback as they read, without “giving away” answers to the multiple-choice
questions and programming exercises.
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.
KEY TERMS: Each chapter includes a list of newly introduced vocabulary, shown in the
order of appearance in the text. The list of key terms provides a short review of the major
concepts in the chapter.
SUMMARIES: Following each chapter is a summary that recaps the programming
concepts and techniques covered in the chapter. This feature provides a concise means for
students to 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.
GAME ZONE: Each chapter provides one or more exercises in which students can create
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.
CASES: Each chapter contains two running case problems. These cases represent projects
that continue to grow throughout a semester using concepts learned in each new chapter.
Two cases allow instructors to assign different cases in alternate semesters or to divide
students in a class into two case teams.
Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
PREFACE Instructor Resources
GLOSSARY: This edition contains an alphabetized list of all key terms identified in the
book, along with their definitions.
APPENDICES: This edition includes useful appendices on working with the Java platform,
data representation, formatting output, generating random numbers, and creating Javadoc
comments.
xxiv
QUALITY: Every program example, exercise, and game solution was tested by the author
and then tested again by a quality assurance team using Java Standard Edition (SE) 8, the
most recent version available.
CourseMate
The more you study, the better the results. Make the most of your study time by accessing
everything you need to succeed in one place. Read your textbook, take notes, review
flashcards, watch videos, and take practice quizzes online. CourseMate goes beyond the book
to deliver what you need! Learn more at www.cengage.com/coursemate.
The Java Programming CourseMate includes:
Debugging Exercises: Four error-filled programs accompany each chapter. By
debugging these programs, students can gain expertise in program logic in general and
the Java programming language in particular.
Video Lessons: Each chapter is accompanied by at least three video lessons that help to
explain important chapter concepts. These videos were created and narrated by the
author.
Interactive Study Aids: An interactive eBook, quizzes, flashcards, and more!
Instructors may add CourseMate to the textbook package, or students may purchase
CourseMate directly at www.CengageBrain.com.
Instructor Resources
The following teaching tools are available for download at our Instructor Companion Site.
Simply search for this text at sso.cengage.com. An instructor login is required.
Electronic Instructor’s Manual: The Instructor’s Manual that accompanies this
textbook contains additional instructional material to assist in class preparation,
including items such as Overviews, Chapter Objectives, Teaching Tips, Quick
Quizzes, Class Discussion Topics, Additional Projects, Additional Resources, and Key
Terms. A sample syllabus is also available. Additional exercises in the Instructor’s
Manual include:
Tough Questions: Two or more fairly difficult questions that an applicant
might encounter in a technical job interview accompany each chapter. These
questions are often open-ended; some involve coding and others might involve
research.
Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Acknowledgments
Acknowledgments
I would like to thank all of the people who helped to make this book a reality, including Dan
Seiter, Development Editor; Alyssa Pratt, Senior Content Developer; Carmel Isaac, Content
Project Manager; and Chris Scriver and Danielle Shaw, quality assurance testers. I am lucky to
work with these professionals who are dedicated to producing high-quality instructional
materials.
I am also grateful to the reviewers who provided comments and encouragement during this
book’s development, including Bernice Cunningham, Wayne County Community College
District; Bev Eckel, Iowa Western Community College; John Russo, Wentworth Institute of
Technology; Leslie Spivey, Edison Community College; and Angeline Surber, Mesa
Community College.
Thanks, too, to my husband, Geoff, for his constant support and encouragement. Finally, this
book is dedicated to the newest Farrell, coming March 2015. As this book goes to production,
I don’t know your name or even your gender, but I do know that I love you.
Joyce Farrell
Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Read This Before
xxvi
You Begin
The following information will help you as you prepare to use this textbook.
Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Features
This text focuses on helping students become better programmers and understand
Java program development through a variety of key features. In addition to Chapter
Objectives, Summaries, and Key Terms, these useful features will help students
regardless of their learning styles. xxvii
NOTES provide
additional information—
for example, another
location in the book that
expands on a topic, or a
common error to watch
out for.
Drop Time
No. 1 Interval No.
Sec. Charge
Volts Sec. between Electrons
per in
Discharges Emitted
per Cm. Cm.
in Seconds
2.260 11.0 - 1200} {49.4}
3.070 11.0 + 32.8} {50.5}
11 4.4 1
1.960 + 194 54.4
12.8
1.960 + 190 60.8 6.4 1
23
1.820 11.2 + 220 65.0 4.2 1
40.0
1.690 + 230 69.8 4.8 1
15.2
1.550 + 332 75.1 5.3 1
Drop
3.040 No. 2 + 98 43.5
10.4
5.6
Drop Time
No. 1 Interval No.
Sec. Charge
Volts Sec. between Electrons
per in
Discharges Emitted
per Cm. Cm.
in Seconds
2.540 + 200 49.4 5.9 1
18.6
2.230 + 300 55.2 5.8 1
35.0
2.230 + 76 60.7 5.5 1
42.0
1.930 + 200 65.0 4.3 1
54
1.810 + 176 69.6 4.6 1
70
1.650 + 250 75.2 5.6 1
45
1.520 + 500 79.4 4.2 1
9.8
1.520 + 119 85.1 5.5 1
Mean 29 Mean 5.1
V. IONIZATION BY -RAYS
But what happens to the electronic constituents of an atom when
an -particle, that is, a helium atom, shoots through it? Some of
Bragg’s experiments and Wilson’s photographs show that the -
particles shoot in straight lines through from 3 to 7 cm. of air before
they are brought to rest. We must conclude, then, that an atom has
so loose a structure that another atom, if endowed with enough
speed, can shoot straight through it without doing anything more
than, in some instances, to shake off from that atom an electron or
two. The tracks shown in Figs. 14 and 15, facing p. 190, are Wilson’s
photographs of the tracks of the -particles of radium. They ionize
so many of the atoms through which they pass that the individual
droplets of water which form about the ions produced along the path
of the ray, and which are the objects really photographed, are not
distinguishable as individuals. The sharp changes in the direction of
the ray toward the end of the path are convincing evidence that the
-particle actually goes through the atoms instead of pushing them
aside as does a bullet. For if one solar system, for example,
endowed with a stupendous speed, were to shoot straight through
another similar system, but without an actual impact of their central
bodies, the deflection from its straight path which the first system
experienced might be negligibly small if its speed were high enough,
and that for the simple reason that the two systems would not be in
each other’s vicinity long enough to produce a deflecting effect. In
technical terms the time integral of the force would be negligibly
small. The slower the speed, however, the longer this time, and
hence the greater the deflection. Thus it is only when the -particle
shown in Fig. 15 has lost most of its velocity—i.e., it is only toward
the end of its path—that the nuclei of the atoms through which it
passes are able to deflect it from its straight path. If it pushed the
molecules aside as a bullet does, instead of going through them, the
resistance to its motion would be greatest when the speed is highest.
Now, the facts are just the opposite of this. The -particle ionizes
several times more violently toward the end of its path than toward
the beginning, and it therefore loses energy more rapidly when it is
going slowly than when it is going rapidly. Further, it is deflected
more readily, then, as the photograph shows. All of this is just as it
should be if the -particle shoots straight through the molecules in
its path instead of pushing them aside.
These photographs of Wilson’s are then the most convincing
evidence that we have that the atom is a sort of miniature stellar
system with constituents which are unquestionably just as minute
with respect to the total volume occupied by the atom as are the sun
and planets and other constituents of the solar system with respect
to the whole volume inclosed within the confines of this system.
When two molecules of a gas are going as slowly as they are in the
ordinary motion of thermal agitation, say a mile a second, when their
centers come to within a certain distance—about 0.2 . (millionths
of a millimeter)—they repel one another and so the two systems do
not interpenetrate. This is the case of an ordinary molecular collision.
But endow one of these molecules with a large enough energy and it
will shoot right through the other, sometimes doubtless without so
much as knocking out a single electron. This is the case of an -
particle shooting through air
But the question to which we are here seeking an answer is,
does an individual -particle ever knock more than one electron
from a single atom or molecule through which it passes, so as to
leave that atom doubly or trebly charged? The oil-drop method used
at low pressures[65] has given a very definite answer to this question.
In no gas or vapor except helium, which we have as yet tried, is
them any certain evidence that an individual -ray in shooting
through an atom is able to remove from that atom more than one
single electron at a time.
The foregoing result has been obtained by shooting the -rays
from polonium through a rarefied gas in an oil-drop apparatus of the
type sketched in Fig. 12, catching upon a balanced oil drop the
positively charged residue of one of the atoms thus ionized, and
counting, by the change in speed imparted to the droplet, the
number of electrons which were detached from the captured atom by
the passage of the -ray through or near it.[66]
This mode of experimenting extended to helium, however, has
yielded the most interesting result[67] that every sixth one on the
average of all the passages, or “shots,” which detached any
electrons at all from the helium atom detached both of the two
electrons which the neutral helium atom possesses. Since some of
the ionization produced along the path of an -ray is probably due to
slow-speed secondary -rays produced by the -ray, it is probable
that the fraction of the actual passages through helium atoms of -
rays themselves which detach both electrons is greater than the
foregoing one in six. It has been estimated by Fowler at as high as
three in four.
The foregoing experimental result of one in six was obtained only
at the very end of the range of the -rays where they have their
maximum ionizing power. When these rays were near the beginning
of their range, and therefore were moving much more rapidly, the
fraction of the number of double catches to total catches was only
about half as much, i.e., the chance of getting both electrons at a
single shot is much smaller with a high-speed bullet than with a slow-
speed one. This is to be expected if the two electrons are
independent of each other, i.e., if the removal of one does not carry
the other out with it.
The foregoing is, I think, the only experiment which has yet been
devised in which the act of ionization is isolated and studied as an
individual thing.
Since 1913, however, very definite evidence has come in from
two different sources that multiply-valent. ions are often produced in
discharge tubes. The most unambiguous proof of this result has
been furnished by the spectroscope. Indeed, Mr. Bowen and the
author have recently found with great definiteness that high-voltage
vacuum sparks give rise to spectral lines which are due to singly-,
doubly-, trebly-, quadruply-, and quintuply- charged atoms of the
elements from lithium to nitrogen, and even to sextuply-charged
ones in the case of sulphur.[68] In view of the foregoing studies with
X-rays, -rays, and -rays, it is probable that these
spectroscopically discovered multiply-charged ions are produced by
successive ionizations such as might be expected to take place in a
region carrying a very dense electron current, such as must exist in
our “hot-sparks.”
Again, J. J. Thomson has brought forward evidence[69] that the
positive residues of atoms which shoot through discharge tubes in a
direction opposite to that of the cathode rays have suffered multiple
ionization. Indeed, he thinks he has evidence that the act of
ionization of atoms of mercury consists either in the detachment of
one negative electron or else in the detachment of eight. His
evidence for the existence in the case of mercury of multiple charges
from one up to eight is certainly very convincing, and it is possible,
also, that under his conditions the act of ionization itself may consist
in the detachment either of one or of eight electrons as he suggests.
Further evidence upon this point must be sought.
VI. SUMMARY
The results of the studies reviewed in this chapter may be
summarized thus:
1. The act of ionization by -rays seems to consist in the shaking
off without any appreciable energy of one single electron from an
occasional molecule through which the -ray passes. The faster the
-ray the less frequently does it ionize.
2. The act of ionization by ether waves, i.e., by X-rays or light,
seems to consist in the hurling out with an energy which may be very
large, but which depends upon the frequency of the incident ether
wave, of one single electron from an occasional molecule over which
this wave passes.
3. The act of ionization by rapidly moving -particles consists
generally in the shaking loose of one single electron from the atom
through which it passes, though in the case of helium, two electrons
are certainly sometimes removed at once. It may be, too, that a very
slow-moving positive ray, such as J. J. Thomson used, may detach
several electrons from a single atom.
CHAPTER VII
BROWNIAN MOVEMENTS IN GASES
I. HISTORICAL SUMMARY
In 1827 the English botanist, Robert Brown, first made mention of
the fact that minute particles of dead matter in suspension in liquids
can be seen in a high-power microscope to be endowed with
irregular wiggling motions which strongly suggest “life.”[70] Although
this phenomenon was studied by numerous observers and became
known as the phenomenon of the Brownian movements, it remained
wholly unexplained for just fifty years. The first man to suggest that
these motions were due to the continual bombardment to which
these particles are subjected because of the motion of thermal
agitation of the molecules of the surrounding medium was the
Belgian Carbonelle, whose work was first published by his
collaborator, Thirion, in 1880,[71] although three years earlier
Delsaulx[72] had given expression to views of this sort but had
credited Carbonelle with priority in adopting them. In 1881
Bodoszewski[73] studied the Brownian movements of smoke
particles and other suspensions in air and saw in them “an
approximate image of the movements of the gas molecules as
postulated by the kinetic theory of gases.” Others, notably Gouy,[74]
urged during the next twenty years the same interpretation, but it
was not until 1905 that a way was found to subject the hypothesis to
a quantitative test. Such a test became possible through the brilliant
theoretical work of Einstein[75] of Bern, Switzerland, who, starting
merely with the assumption that the mean kinetic energy of agitation
of a particle suspended in a fluid medium must be the same as the
mean kinetic energy of agitation of a gas molecule at the same
temperature, developed by unimpeachable analysis an expression
for the mean distance through which such a particle should drift in a
given time through a given medium because of this motion of
agitation. This distance could be directly observed and compared
with the theoretical value. Thus, suppose one of the wiggling
particles is observed in a microscope and its position noted on a
scale in the eyepiece at a particular instant, then noted again at the
end of (for example, 10) seconds, and the displacement in that
time along one particular axis recorded. Suppose a large number of
such displacements in intervals all of length are observed,
each one of them squared, and the mean of these squares taken
and denoted by : Einstein showed that the theoretical value of
should be
This was the form which Einstein originally gave to his equation, a
very simple derivation of which has been given by Langevin.[76] The
essential elements of this derivation will be found in Appendix C.
The first careful test of this equation was made on suspensions in
liquids by Perrin,[77] who used it for finding the number of
molecules in a gram molecule. He obtained the mean value
, which, in view of the uncertainties in the
measurement of both and , may be considered as proving
the correctness of Einstein’s equation within the limits of error of
Perrin’s measurements, which differ among themselves by as much
as 30 per cent.
The mean was next measured for a great many particles and
introduced into Einstein’s equation:
We obtain thus
or
The possibility of thus eliminating the size of the particle and with
it the resistance of the medium to its motion can be seen at once
from the simple consideration that so long as we are dealing with
one and the same particle the ratio between the force acting and
the velocity produced by it must be the same, whether the acting
force is due to gravity or an electrical held, as in the oil-drop
experiments, or to molecular impacts as in Brownian-movement
work. De Broglie might have made such an elimination and
calculation of in his work, had his Brownian displacements and
mobilities in electric fields been made on one and the same particle,
but when the two sets of measurements are made on different
particles, such elimination would involve the very uncertain
assumption of identity of the particles in both charge and size.
Although De Broglie did actually make this assumption, he did not
treat his data in the manner indicated, and the first publication of this
method of measuring as well as the first actual determination
was made in the papers mentioned above.
Some time later E. Weiss reported similar work to the Vienna
Academy.[87]
2. Although it is possible to make the test of in just the
method described and although it was so made in the case of one or
two drops, Mr. Fletcher worked out a more convenient method,
which involves expressing the displacements in terms of the
fluctuations in the time required by the particle to fall a given
distance and thus dispenses with the necessity of balancing the drop
at all. I shall present another derivation which is very simple and yet
of unquestionable validity.
In equation (28) let be the time required by the particle, if there
were no Brownian movements, to fall between a series of equally
spaced cross-hairs whose distance apart is . In view of such
movements the particle will have moved up or down a distance
in the time . Let us suppose this distance to be up. Then the actual
time of fall will be , in which is now the time it takes the
particle to fall the distance . If now is small in comparison
with , that is, if is small in comparison with (say ⅒ or less),
then we shall introduce a negligible error (of the order ¹⁄₁₀₀ at the
most) if we assume that in which is the mean
velocity under gravity. Replacing then in (28) ( , by in
which is the square of the average difference between an