World Headquarters
Jones & Bartlett Learning
5 Wall Street
Burlington, MA 01803
978-443-5000
www.jblearning.com
Jones & Bartlett Learning books and products are available through most bookstores and online booksellers. To contact Jones & Bartlett Learning directly, call 800-832-0034, fax 978-443-8000, or visit our website, www.jblearning.com.
Substantial discounts on bulk quantities of Jones & Bartlett Learning publications are available to corporations, professional associations, and other qualified organizations. For details and specific discount information, contact the special sales department at Jones & Bartlett Learning via the above contact information or send an email to .
Copyright 2016 by Jones & Bartlett Learning, LLC, an Ascend Learning Company
All rights reserved. No part of the material protected by this copyright may be reproduced or utilized in any form, electronic or mechanical, including photocopying, recording, or by any information storage and retrieval system, without written permission from the copyright owner.
The content, statements, views, and opinions herein are the sole expression of the respective authors and not that of Jones & Bartlett Learning, LLC. Reference herein to any specific commercial product, process, or service by trade name, trademark, manufacturer, or otherwise does not constitute or imply its endorsement or recommendation by Jones & Bartlett Learning, LLC and such reference shall not be used for advertising or product endorsement purposes. All trademarks displayed are the trademarks of the parties noted herein. Java Illuminated, Fourth Edition, is an independent publication and has not been authorized, sponsored, or otherwise approved by the owners of the trademarks or service marks referenced in this product.
There may be images in this book that feature models; these models do not necessarily endorse, represent, or participate in the activities represented in the images. Any screenshots in this product are for educational and instructive purposes only. Any individuals and scenarios featured in the case studies throughout this product may be real or fictitious, but are used for instructional purposes only.
05782-9
Production Credits
Executive Publisher: William Brottmiller
Publisher: Cathy L. Esperti
Acquisitions Editor: Laura Pagluica
Associate Production Editor: Sara Kelly
Associate Marketing Manager: Cassandra Peterson
VP, Manufacturing and Inventory Control: Therese Connell
Composition: diacriTech
Cover & Title Page Design: Scott Moden
Rights and Photo Research Coordinator: Ashley Dos Santos
Cover & Title Page Image: Kyle Smith/ShutterStock, Inc.
Printing and Binding: Courier Companies
Cover Printing: Courier Companies
Library of Congress Cataloging-in-Publication Data
Anderson, Julie, 1947
Java illuminated / Julie Anderson, Rollins College, Herv J. Franceschi, Capitol College.
Fourth edition.
pages cm
Includes bibliographical references and index.
ISBN 978-1-284-04531-4 (pbk.)
1. Java (Computer program language) I. Franceschi, Herv. II. Title.
QA76.73.J3A533 2015
005.133dc23
2014024734
6048
Printed in the United States of America
18 17 16 15 14 10 9 8 7 6 5 4 3 2 1
Dedications
To the memory of my parents, Glenn and Rosemary Austin, my first teachers. Julie Anderson
A ma mre, trop tt disparue, et mon pre. Herv Franceschi
Contents
Preface
Purpose of This Text and Its Audience
Java Illuminated, Fourth Edition, covers all of the material required for the successful completion of an introductory course in Java. While the focus is on the material required for the Computer Science I (CS1) and Computer Science II (CS2) curricula, students enrolled in Information Systems, Information Technology, or self-directed study courses will find the text useful as well. It has been written to provide introductory computer science students with a comprehensive overview of the fundamentals of programming using Java as the teaching language. In addition, the text presents other topics of interest, including graphical user interfaces (GUI), data structures, file input and output, applets, and graphical applications.
Throughout the text, we take an active learning approach to presenting the material. Instead of merely presenting the concepts to students in a one-sided, rote manner, we ask them to take an active role in their understanding of the concepts through the use of numerous interactive examples, exercises, and projects.
Coverage and Approach
Our approach is to teach object-oriented programming in a progressive manner. We start in , we present inheritance, polymorphism, and interfaces. Throughout the text, we present concepts in an object-oriented context.
Our philosophy is to emphasize good software engineering practices by focusing on designing and writing correct, maintainable programs. As such, we discuss pseudocode, testing techniques, design trade-offs, and other software engineering tips.
We teach the student basic programming techniques, such as accumulation, counting, calculating an average, finding maximum and minimum values, using flag and toggle variables, and basic searching and sorting algorithms. In doing so, we emphasize the patterns inherent in programming. Concepts are taught first, followed by fully implemented examples with source code. We promote Java standards, conventions, and methodologies.
This text supports the important features of the latest versions of Java (58). The Scanner class is used to simplify user input from the keyboard and in reading from files. In .
Learning Features
Recognizing todays students growing interest in animation and visualization, we distribute techniques for producing graphical output and animation throughout the book, starting in with applets and graphical applications. An example using either animation or graphical output is included in most chapters. Instructors who are not interested in incorporating graphics into their curriculum can simply skip these sections. In addition, some of our examples are small games, which we find motivational for students.
In each chapter, we include one or two Programming Activities, which are designed to provide visual feedback to the students so that they can assess the correctness of their code. In most Programming Activities, we provide a framework, usually with a graphical user interface, to which the student adds code to complete the application. The student should be able to finish the Programming Activity in about 15 to 20 minutes; thus, these activities can be used in the classroom to reinforce the topics just presented. Each Programming Activity also includes several discussion questions that test the students understanding of the concepts the activity illustrates. The Programming Activities are also appropriate for a closed or open laboratory environment. In short, this text can be used in a traditional lecture environment, a computer-equipped classroom, or a lab environment.
In addition, we supplement each chapter with a browser-based module that animates sample code, visually illustrating the assignment of variable values, evaluation of conditions, and flow of control.
We also provide the instructor and students with an extensive variety of end-of-chapter material: multiple-choice questions, examples that ask the student to predict the output of prewritten code or to fill in missing code, debugging activities, short exercises, programming projects, technical writing assignments, a learning-to-learn exercise called Look It Up, and a higher-difficulty group project.
Next page