Professional Documents
Culture Documents
Absolute Java 6Th Global Edition by Walter Savitch Full Chapter
Absolute Java 6Th Global Edition by Walter Savitch Full Chapter
VIDEO NOTES
VideoNotes are step-by-step videos that guide readers through the solution to an end-of-
chapter problem or further illuminate a concept presented in the text. Icons in the text
VideoNote
indicate where a VideoNote enhances a topic. Fully navigable problems allow for self-
paced instruction. VideoNotes are located at www.pearsonglobaleditions.com/savitch.
OTHER FEATURES
Pitfall sections, programming tip sections, and examples of complete programs with
sample I/O are given throughout each chapter. Each chapter ends with a summary
section and a collection of programming projects suitable to assign to students.
SUPPORT MATERIAL
The following support materials are available to all users of this Global Editions book
at www.pearsonglobaleditions.com/savitch:
■ Source code from the book
ACKNOWLEDGMENTS
Numerous individuals have contributed invaluable help and support in making this
book happen: My former editor, Susan Hartman at Addison-Wesley, first conceived of
the idea for this book and worked with me on the first editions; My current editor, Matt
8 Preface
Goldstein, provided support and inspiration for getting subsequent editions reviewed,
revised, and out the door; Kelsey Loanes, Rose Kernan, Demetrius Hall, and the other
fine people at Pearson also provided valuable assistance and encouragement.
The following reviewers provided corrections and suggestions for this book. Their
contributions were a great help. I thank them all. In alphabetical order they are:
Jim Adams Chandler-Gilbert Community College
Gerald W. Adkins Georgia College & State University
Dr. Bay Arinze Drexel University
Tamara Babaian Bentley University
James Baldo George Mason University
Prof. Richard G. Baldwin Austin Community College
Kevin Bierre Rochester Institute of Technology
Jon Bjornstad Gavilan College
Janet Brown-Sederberg Massasoit Community College
Tom Brown Texas A&M University, Commerce
Charlotte Busch Texas A&M University, Corpus Christi
Stephen Chandler NW Shoals Community College
Hong Cheng Southern Arkansas University
KY Daisy Fan Cornell University
Adrienne Decker University of Buffalo
Brian Downs Century College
Jeffrey Edgington University of Denver
Keith Frikken Miami University
Ahmad Ghafarian North Georgia College & State University
Arthur Geis College of DuPage
Massoud Ghyam University of Southern California
Susan G. Glenn Gordon College
Nigel Gwee Louisiana State University
Judy Hankins Middle Tennessee State University
May Hou Norfolk State University
Sterling Hough NHTI
Chris Howard DeVry University
Eliot Jacobson University of California, Santa Barbara
Balaji Janamanchi Texas Tech University
Suresh Kalathur Boston University
Edwin Kay Lehigh University
Dr. Clifford R. Kettemborough IT Consultant and Professor
Preface 9
13
This page intentionally left blank
Contents
15
16 Contents
Chapter Summary 83
Answers to Self-Test Exercises 84
Programming Projects 86
4.3 Overloading 250
Rules for Overloading 250
PITFALL: Overloading and Automatic Type Conversion 254
PITFALL: You Cannot Overload Based on the Type Returned 256
4.4 Constructors 258
Constructor Definitions 258
TIP: You Can Invoke Another Method in a Constructor 266
TIP: A Constructor Has a this Parameter 266
TIP: Include a No-Argument Constructor 267
Example: The Final Date Class 268
Default Variable Initializations 269
An Alternative Way to Initialize Instance Variables 269
Example: A Pet Record Class 270
The StringTokenizer Class ★ 274
8.1 Polymorphism 516
Late Binding 517
The final Modifier 519
Example: Sales Records 520
Late Binding with toString 527
PITFALL: No Late Binding for Static Methods 528
Downcasting and Upcasting 529
PITFALL: Downcasting 533
22 Contents
ArrayIndexOutOfBoundsException 604
1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if
you provide access to or distribute copies of a Project
Gutenberg™ work in a format other than “Plain Vanilla ASCII” or
other format used in the official version posted on the official
Project Gutenberg™ website (www.gutenberg.org), you must, at
no additional cost, fee or expense to the user, provide a copy, a
means of exporting a copy, or a means of obtaining a copy upon
request, of the work in its original “Plain Vanilla ASCII” or other
form. Any alternate format must include the full Project
Gutenberg™ License as specified in paragraph 1.E.1.
• You pay a royalty fee of 20% of the gross profits you derive from
the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”
• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.
1.F.
Most people start at our website which has the main PG search
facility: www.gutenberg.org.