Professional Documents
Culture Documents
Textbook Java Programming Joyce Farrell Ebook All Chapter PDF
Textbook Java Programming Joyce Farrell Ebook All Chapter PDF
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: permissionrequest@cengage.com.
©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.
The eggs are produced by Perlidae in enormous numbers: they are rather
small, but peculiar in form, and possess at one extremity a micropyle
apparatus, covered by a glassy substance through which Imhof could find
no orifice. On the other hand, the chorion on another part of the egg is
perforated by several canals.
It has been observed that in some Perlidae the eggs, after they have
been extruded, are carried about by the female; for what reason is not at
all known. They are said to be enclosed in a membranous capsule at the
apex of the abdomen. The number of eggs deposited is sometimes very
large, amounting to five or six thousand, and they are often of very minute
size.
The family in its character comes near to the Orthoptera, especially to the
more simple forms of Phasmidae, but the two groups differ in the texture
of the front wings and in the structure of the mouth-parts, as well as in the
different proportions of the mesothorax and metathorax. According to
Pictet, in the Australian genus Eusthenia the trophi (Fig. 259) approach
nearer to those of the Orthoptera, so that it appears possible that a more
intimate connexion will be found to exist as more forms are discovered.
Of the groups we include in Neuroptera, Perlidae are in structure most
allied to Sialidae, but the development in the two groups exhibits very
important distinctions. Brauer treats the Perlidae as forming a distinct
Order called Plecoptera, a name applied to the family by Burmeister
many years ago.
Brongniart informs us[330] that several fossils have been found in the
Carboniferous strata of Commentry that justify us in asserting that allies
of Perlidae then existed. He considers these Carboniferous Insects to
have belonged to a separate family, Protoperlides. The fragments are,
however, so small that we must await further information before forming a
definite opinion as to these Protoperlides.
CHAPTER XVIII
Elongate Insects with very mobile head and large eyes, with small
and inconspicuous antennae ending in a bristle; with four elongate
wings sub-equal in size and similar in texture, of papyraceous
consistency and having many veinlets, so that there exists a large
number of small cells. All the legs placed more anteriorly than the
wings. The earlier stages of the life are aquatic; there is great change
in the appearance of the individual at the final ecdysis, but there is no
pupal instar.
The dragon-flies form a very natural and distinct group of Insects. All the
species are recognised with ease as belonging to the family. They are
invariably provided with wings in the perfect state, and many of them are
amongst the most active of Insects. Their anatomy is, in several respects,
very remarkable.
The eyes are always large; in some cases they are even enormous, and
occupy the larger part of the area of the head: the upper facets of the eye
are in many cases larger than the lower, and in a few forms the line of
division is sharply marked transversely. There are three ocelli, which,
when the size of the compound eyes is not too great, are placed in the
usual manner as a triangle on the vertex; but in the forms where the
compound eyes are very large the portion of the head between is, as it
were, puffed out so as to form a projection just in front of where the eyes
meet, and one ocellus is then placed on each side of this projection, an
antenna being inserted quite close to it; the third ocellus is placed in front
of the projection we have mentioned, by which it is often much concealed;
this anterior ocellus is in some cases of unusually large size, and oval or
transverse in form.
Fig. 260.—Anax formosus, Britain. (After Migneaux.) (The legs are not in a
natural position.)
The parts of the mouth are very peculiar, especially the lower lip: we will
briefly allude to its characters in the highly modified forms, premising that
in the smaller and less active species it is less remarkable. The
Libellulidae are carnivorous, their prey being living Insects which are
captured by the dragon-fly on the wing; it is believed that the mouth is
largely instrumental in the capture, though the flight of these Insects is so
excessively rapid that it is difficult, if not impossible, to verify the action of
the mouthpieces by actual observation.
The meso- and meta-thorax are very intimately combined, and their
relations are such that the former is placed much above the latter. This
peculiarity is carried to its greatest extent in some of the Agrioninae (Fig.
262, A), where not only are the wings placed at a considerable distance
behind the three pairs of legs, but also the front pair of wings is placed
almost directly above the hind pair. In the Anisopterides these
peculiarities are much less marked (Fig. 262, B), nevertheless even in
them the three pairs of legs are placed quite in front of the wings. This
peculiar structure of the wing-bearing segments is accompanied by an
unusual development of the pleura, which, indeed, actually form the
larger part, if not nearly the whole, of the front region of the dorsal aspect
of these two segments. We shall not enter into more minute particulars as
to the structure of the thorax, for difference of opinion prevails as to the
interpretation of the parts.[332] The abdomen is remarkable for its
elongation; it is never broad, and in some genera—Mecistogaster, e.g.—it
attains a length and slenderness which are not reached by any other
Insects. It consists of ten segments and a pair of terminal calliper-like or
flap-like processes of very various sizes and forms.
The wings of the dragon-flies are usually transparent and provided with a
multitude of small meshes. The hind wings are about as large as the front
pair, or even a little larger; the main nervures have a sub-parallel course,
and are placed in greater part on the anterior region of each wing. The
relations of the more constant nervures and the cells of which they are
parts form a complex subject, and are amongst the most important of the
characters used in classifying these Insects. The wings are always
elongate in comparison to their breadth and have no folds; they are held
partially extended, or are placed so as to project backwards, or
backwards and outwards. They exhibit another peculiarity, inasmuch as
the front or costal margin is slightly uneven before or near the middle,
giving rise to an appearance such as might result from the breaking and
subsequent mending of the marginal rib at the spot in question, which is
called the nodus. In some forms a peculiar character exists in the shape
of a small opaque space called the membranule, lying close to the body
of the Insect in the anal area of the wing, as shown in Fig. 260.
The legs are slender and are chiefly remarkable for the beautiful series of
hair-like spines with which they are armed, and which in some forms (e.g.
Platycnemis, Fig. 264) are of considerable length. We believe that the
legs are of great importance in capturing the prey, they being held
somewhat in the position shown in Fig. 262, C. The tarsi are three-jointed.
In the male of Libellago caligata the legs exhibit a remarkable condition,
the tibiae being dilated, and on the upper side of a vivid red colour, while
below they are white. This coloration and form are each unusual in the
family. The male of Platycnemis pennipes, a British species (Fig. 264),
shows a similar dilatation of the tibiae, but to a less extent and without
any great difference in the colour of the two faces of the dilatation. This
dilatation reaches its maximum in Psilocnemis dilatipes M‘Lach. The
position of the legs in relation to the other parts of the body is peculiar to
the dragon-flies; the legs seem to be unfit for walking, the Insects never
using them for that purpose.
The eggs are deposited either in the water or in the stem of some aquatic
plant, the female Insect occasionally undergoing submersion in order to
accomplish the act. The young on hatching are destitute of any traces of
wings (Fig. 265), and the structure of the thoracic segments is totally
different from what it is in the adult, the rectal respiratory system (Fig.
265, x) to which we shall subsequently allude, being, however, already
present. The wings are said to make their first appearance only at the
third or fourth moult. At this time the pleura of the second and third
thoracic segments have grown in a peculiar manner so as to form a
lateral plate (Fig. 266, B, shows this plate at a later stage), and the wing-
pads appear as small projections from the membranes at the upper
margins of these pleural plates (Fig. 266, A, B). The plates increase in
size during the subsequent stadia, and meet over the bases of the wing-
pads, which also become much longer than they were at first. The
number of moults that occur during growth has not been observed in the
case of any species, but they are believed to be numerous. There is no
pupa, nor is there any well-marked quiescent stage preceding the
assumption of the winged form at the last ecdysis, although at the latter
part of its life the nymph appears to be more inactive than usual. When
full grown, the nymph is more like the future perfect Insect than it was at
first, and presents the appearance shown in Figs. 266 and 270. At this
stage it crawls out of the water and clings to some support such as the
stem or leaf of an aquatic plant; a few minutes after doing so the skin of
the back of the thoracic region splits, and the imago emerges from the
nymphal skin.
The nymphs never have the body so elongate as the perfect Insect, the
difference in this respect being frequently great, and the nymphs of the
subfamily Libellulinae being very broad (Fig. 266, nymph of Ictinus sp.);
consequently the creature on emergence from the nymph-skin is very
much shorter than it will soon become. Extension begins to take place
almost immediately; it has been thought by some that this is
accomplished by swallowing air; this is, however, uncertain. At first the
wings have only the length of the wing-pads of the nymph, and their
apical portion is an unformed mass. The colour of the perfect Insect is not
present when the emergence takes place. The wing grows quickly until
the full length is attained. In the genus Agrion the expansion of the wings
is accompanied by frequent elevations and depressions of the body, and
occupies an hour or so; the elongation of the abdomen is not so soon
completed, and its brilliant colours do not appear for several hours.
The mouth of the nymph bears a remarkable structure called the mask
(Fig. 268). It is apparently formed by a backward growth of the bases of
the labium and lingua, a hinge being formed between the two at the most
posterior point of their growth. The prolonged portions of these parts are
free: usually the mask is folded under the head, but it can be unfolded
and thrust forward, remaining then attached to the head by means of the
more anterior parts of the lingua and by the maxillae, the whole of the
elongate apparatus being, when used, extended from this anterior part of
its attachment. The front parts of the labium form a prehensile apparatus
armed with sharp teeth, so that the structures make altogether a very
effectual trap, that can be extended in order to secure the prey.
The fact that the dragon-fly passes suddenly, in the middle of its
existence, from an aquatic to an aerial life, makes the condition of its
respiratory organs a subject for inquiry of more than usual interest.
Réaumur was of opinion that the nymph was, in spite of its aquatic
existence, provided with an extensive system of stigmata or orifices for
breathing air; this was, however, denied by Dufour, and his opinion
seemed to be supported by the fact that other means of obtaining air
were discovered to exist in these nymphs. The inquiries connected with
the respiration of Odonata are still very incomplete, but some interesting
points have been ascertained, the most important of which is perhaps the
existence in some forms of a respiratory system in connexion with the
posterior part of the alimentary canal (Fig. 269). In the nymphs of
Anisopterides the system consists of four main tracheal trunks, traversing
the length of the body, and by their ramifications and inosculations
forming an extensive apparatus. Connected with the four main trunks we
have described, there is a shorter pair confined to the abdomen, where it
supplies a large number of branches to the walls of the stomach. The
dorsal pair of the main tubes give numerous subsidiary branches to the
outside of the rectum, and the ventral pair furnish a smaller number. The
walls of the gut are penetrated by the branches, which inside the rectum
form numerous loops; these, covered by a membrane, project into the
interior in the form of multitudinous papillae (Æschninae). In the
Libellulinae the papillae are replaced by more flattened processes or
lamellae. The structures attain a remarkable development, there being in
Aeschna cyanea upwards of 24,000 papillae.
These rectal gills obtain air from water admitted into the rectum for the
purpose; the extremity of the body being armed with projections of
variable form, that can be separated to allow ingress and egress of the
fluid, or brought into close apposition so as to close the orifice. The water
so taken in can, by some species, be ejected with force, and is used
occasionally as a means of locomotion. These rectal branchiae can
absorb free air, as well as air dissolved in water. If the fluid in which the
creatures are placed has been previously boiled, so as to expel the air
from it, the nymphs then thrust the extremity of the body out of the water
and so obtain a supply of air.
Oustalet and Palmén state that at the last ecdysis the lamellae, or the
papillae, do not disappear, but remain quite empty, and are consequently
functionless, while on the tracheal trunks there are developed air vesicles
to fit the creature for its aerial career. Hagen says that in Epitheca the
whole structure of the gills is shed at the final moult.
The subject of the rectal branchiae of Libellula has been discussed and
illustrated by Chun,[338] who states that Leydig has made known that in
Phryganea grandis a structure is found connecting the rectal branchiae of
Libellula with the rectal glands of some other Insects. We have not been
able to find a confirmation of this in the writings of Leydig or elsewhere.
Fig. 270.—Calepteryx virgo, mature nymph, Britain.