Preface

Writing the Second Edition

The exam for the Sun Certified Programmer for Java 2 (SCPJ2) Platform has changed considerably since the first edition of this book was published. The most noticeable change in the current version of the exam (SCPJ2 1.4) is the removal of GUI and I/O, and the shifting of emphasis toward the core features of the language. In our opinion, the new exam demands an even greater understanding and actual experience of the language, rather than mere recitation of facts. Proficiency in the language is the key to success.

The I/O and GUI topics of the first edition have been eliminated, as they have no relevance for the SCPJ2 exam. These topics are more relevant for the Sun Certified Developer for Java 2 (SCDJ2) Platform exam and, therefore, relegated to a possible future volume on the Developer exam topics.

Since the emphasis of the SCPJ2 exam is on the core features of Java, the second edition provides an even greater in-depth coverage of the relevant topics. The book covers not just the exam objectives, but also supplementary topics that aid in mastering the exam topics.

The second edition is still a one-source guide for the SCPJ2 exam: it provides a mixture of theory and practice for the exam. Use the book to learn Java, pass the SCPJ2 exam, and afterwards, use it as a handy language guide. The book also has an appendix devoted to the SCPJ2 Upgrade exam. To facilitate preparation for the exams, the second edition comes with a CD containing additional resources, including several mock exams developed by Whizlabs Software.

We have taken into consideration the feedback we have received from readers. The many hours spent in handling the deluge of e-mail have not been in vain. Every single e-mail is appreciated and is hereby acknowledged.

Preparing the second edition dispelled all our illusions about second editions being, to put it colloquially, a piece of cake. Every sentence from the first edition has been weighed carefully, and not many paragraphs have escaped rewriting.

UML (Unified Modeling Language) is also extensively employed in this edition. Numerous new review questions have been added. In covering the new topics and expanding the existing ones, new examples, figures, and tables were also specifically created for the second edition.

About This Book

This book provides an extensive coverage of the Java programming language and its core Application Programming Interfaces (APIs), with particular emphasis on its syntax and usage. The book is primarily intended for professionals who want to prepare for the Sun Certified Programmer for Java 2 Platform 1.4 exam (referred to as the SCPJ2 exam), but it is readily accessible to any programmer who wants to master the language. For both purposes, it provides an in-depth coverage of essential features of the language and its core APIs.

There is a great and increasing demand for certified Java programmers. Sun Microsystems has defined the SCPJ2 exam as one that professionals can take to validate their skills. The certification provides the IT industry with the standard to use for hiring such professionals, and allows the professionals to turn their Java skills into credentials that are important for career advancement.

The book helps the reader master all core features of the Java language, and this mastering of the language can culminate in accomplishing the exam. It provides an extensive coverage of all the objectives defined for the exam by Sun. Since the exam objectives are selective, they do not cover many of the essential features of Java. This book provides extensive coverage of additional topics that every Java programmer should master in order to be proficient in this field. In this regard, the book is a comprehensive primer for learning the Java programming language.

This book is not a complete reference for Java, as it does not attempt to list every member of every class from the Java System Development Kit (SDK) API documentation. Its purpose is not to document the Java SDK APIs. It is also not a book on teaching programming techniques. Its emphasis is on the Java programming language features, their syntax and correct usage.

The book assumes a background in programming. We believe the exam is accessible to any programmer who works through the book. A Java programmer can easily skip over material that is well understood and concentrate on parts that need reinforcing, whereas a programmer new to Java will find the concepts explained from basic principles.

Each topic is explained and discussed thoroughly with examples, and backed by review questions and exercises to reinforce the concepts. The book is not biased toward any particular platform, but provides platform-specific details where necessary.

Using the Book

The reader can choose a linear or a non-linear route through the book, depending on her programming background. Non-Java programmers wishing to migrate to Java can read Chapter 1, which provides a short introduction to object-oriented programming concepts, and the procedure for compiling and running Java applications. For those preparing for the SCPJ2 exam, the book has a separate appendix providing all the pertinent information on taking the exam.

The table of contents, listings of tables, examples, and figures, and a comprehensive index facilitate locating topics discussed in the book.

In particular, we draw attention to the following features of the book:

Exam and Supplementary Objectives

  • Exam objectives are stated clearly at the start of every chapter, together with any supplementary objectives.

  • The objectives are defined by Sun and are organized into major sections, detailing the curriculum for the exam.

  • The book is organized into chapters that logically follow the order of these major sections.

  • The objectives are reproduced in a separate appendix where, for each section of the syllabus, study notes are included to point the reader to topics essential for the exam.

  • We believe that the supplementary objectives are important to the ultimate goal of mastering the language.


Review Questions

Review questions are provided after every major topic, in order to test and reinforce the material. These review questions reflect the kind of questions that can be asked on the actual exam. Annotated answers to the review questions are provided in a separate appendix.

Example 0.1. Example Source Code

We encourage experimenting with the code examples in order to reinforce the material from the book. These can be downloaded from the book Web site (see p. xxxv).

Java code is written in a mono-spaced font. Lines of code in the examples or in code snippets are referenced in the text by a number, which is specified by using a single-line comment in the code. For example, in the following code snippet, the call to the method doSomethingInteresting() hopefully does something interesting at (1).

// ...
doSomethingInteresting();                                                 // (1)
// ...

Names of classes and interfaces start with an uppercase letter. Names of packages, variables, and methods start with a lowercase letter. Constants are all in uppercase letters.

Chapter Summary

Each chapter concludes with a summary of the topics, pointing out the major concepts discussed in the chapter.

Programming Exercises

Programming exercises at the end of each chapter provide the opportunity to put concepts into practice. Solutions to the programming exercises are provided in a separate appendix.

Mock Exam

A complete mock exam is provided in a separate appendix, which the reader can try when she is ready. In addition, the accompanying CD contains several mock exams for the SCPJ2 1.4 exam.

Java 2 SDK and API Documentation

A vertical gray bar is used to highlight methods and fields found in the classes of the core Java APIs.

Any explanation following the API information is also similarly highlighted.


In order to obtain optimal benefit from using this book in preparing for the SCPJ2 exam, we strongly recommend installing the latest version (at least 1.4) of the SDK and its accompanying API documentation. The book focuses solely on Java 2, and does not acknowledge previous versions.

Java 2 Platform Upgrade Exam

For those who have taken the Sun Certified Programmer for Java 2 Platform 1.2 Exam, and would like to prepare for the Sun Certified Programmer for Java 2 Platform Upgrade Exam, we have provided an appendix with details of the upgrade exam. The appendix contains the upgrade exam objectives, and for each section of the syllabus, study notes are included to point the reader to topics essential for the upgrade exam. The accompanying CD contains mock exams for the upgrade exam.

Accompanying CD

The accompanying CD contains a wealth of information to help prepare for the exam, and provides numerous mock exams for the candidate to test her skills. The software included simulates near exam-like conditions in order to acquaint the candidate with the exam environment. Appendix H provides details about the contents of the CD.

Book Web Sites

This book is backed by Web sites providing auxiliary material:

http://www.ii.uib.no/~khalid/pgjc2e/

http://www.awprofessional.com/ (search for ISBN 0201728281)

The contents of the Web sites include the following:

  • source code for all the examples and programming exercises in the book

  • mock exam engine

  • errata

  • links to miscellaneous Java resources (certification, discussion groups, tools, etc.)

Information about the Java 2 SDK Standard Edition and its documentation can be found at the following Web site:

http://java.sun.com/j2se/

The current authoritative technical reference for the Java programming language, The Java Language Specification, Second Edition (also published by Addison-Wesley), can be found at this Web site:

http://java.sun.com/docs/books/jls/

Request for Feedback

Considerable effort has been made to ensure the accuracy of the contents of this book. Several Java professionals have proofread the manuscript. All code examples (including code fragments) have been compiled and tested on various platforms. In the final analysis, any errors remaining are the sole responsibility of the authors.

Any questions, comments, suggestions, and corrections are welcome. Whether the book was helpful or detrimental for your purpose, we would like your assessment. Any feedback is valuable. The authors can be reached by the following e-mail alias:


About the Authors

Khalid A. Mughal

Khalid A. Mughal is an Associate Professor at the Department of Informatics at the University of Bergen, Norway. Professor Mughal is responsible for designing and implementing various courses, which use Java, at the Department of Informatics. Over the years, he has taught Programming Languages (Java, C/C++, Pascal), Software Engineering (Object-oriented System Development), Databases (Data Modeling and Database Management Systems), and Compiler Techniques. He has also given numerous courses and seminars at various levels in object-oriented programming and system development, using Java and Java-related technology, both at the University and for the IT industry. He is the principal author of the book, responsible for writing the material covering the Java topics.

He is also the principal author of an introductory Norwegian textbook on programming in Java (Java som første programmeringsspråk/Java as First Programming Language, Cappelen Akademisk Forlag, ISBN 82-02-21782-2, 2002), which he co-authored with Torill Hamre and Rolf W. Rasmussen.

His primary research is in theory, design, and implementation of programming languages and tools (Programming Environments). His current work involves applying Object Technology in the development of learning content management systems. For the past three years he has been responsible for developing and running a web-based programming course in Java, which is offered to off-campus students.

He is a member of the ACM.

Rolf W. Rasmussen

Rolf W. Rasmussen is a Software Engineer, who over the years has worked both academically and professionally with numerous programming languages, including Java. He is employed as System Creator at vizrt, a company that develops solutions for the TV broadcast industry, including real-time 3D graphic renderers, and content and control systems.

He mainly works on control and automation systems, video processing, typography, and real-time visualization. He has in the past worked on clean room implementations of the Java class libraries, and is a contributor to the Free Software Foundation.

He is primarily responsible for developing the review questions and answers, the programming exercises and their solutions, the mock exam, and all the practical aspects related to taking the SCPJ2 exam, presented in this book.

As mentioned above, he is also a co-author of an introductory textbook on programming in Java.

Acknowledgments (First Edition)

A small application for drawing simple shapes is used in the book to illustrate various aspects of GUI building. The idea for this application, as far as we know, first appeared in Appendix D of Data Structures and Problem Solving Using Java (M.A. Weiss, Addison-Wesley, 1998).

At Addison-Wesley-Longman (AWL), we would like to thank Emma Mitchell for the support and the guidance she provided us right from the start of this project, Martin Klopstock at AWL for accommodating the non-standard procedure involved in getting the book to the printing press, Clive Birks at CRB Associates for providing the professional look to the contents of this book, and finally, Sally Mortimore at AWL for seeing us over the finishing line. The efforts of other professionals behind the scenes at AWL are also acknowledged.

Many reviewers have been involved during the course of writing this book. First of all, we would like to thank the five anonymous reviewers commissioned by AWL to review the initial draft. Their input was useful in the subsequent writing of this book.

Several people have provided us with feedback on different parts of the material at various stages: Jon Christian Lønningdal, Tord Kålsrud, Kjetil Iversen, Roy Oma, and Arne Løkketangen. Their help is hereby sincerely acknowledged.

We are also very grateful to Laurence Vanhelsuwé, Kris Laporte, Anita Jacob, and Torill Hamre for taking on the daunting task of reviewing the final draft, and providing us with extensive feedback at such short notice. We would like to thank Marit Mughal for reading the manuscript with the trained eye of a veteran English schoolteacher.

We now understand why family members are invariably mentioned in a preface. Without our families' love, support, and understanding this book would have remained a virtual commodity. Khalid would like to thank Marit, Nina, and Laila for their love, and for being his pillars of support, during the writing of this book. Thanks also to the folks in Birmingham for cheering us on. Rolf would like to thank Liv, Rolf V., Knut, and Elisabeth for enduring the strange working hours producing this book has entailed. A special thanks to Marit for providing us with scrumptious dinners for consumption at the midnight hour.

Acknowledgments (Second Edition)

Feedback from many readers helped us to improve the first edition. We would like to thank the following readers for their input in this effort:

Michael F. Adolf, Tony Alicea, Kåre Auglænd, Jorge L. Barroso, Andre Beland, Darren Bruning, Paul Campbell, Roger Chang, Joanna Chappel, Laurian M Chirica, Arkadi Choufrine, Barry Colston, John Cotter, Frédéric Demers, Arthur De Souza, djc, William Ekiel, Darryl Failla, John Finlay, Christopher R. Gardner, Marco Garcia, Peter Gieser, George, Paul Graf, Shyamsundar Gururaj, Ray Ho, Leonardo Holanda, Zhu Hongjun, Kara Van Horn, Peter Horst, Nain Hwu, Kent Johnson, Samir Kanparia, Oleksiy Karpenko, Jeffrey Kenyon, Young Jin Kim, Kenneth Kisser, Billy Kutulas, Yi-Ming Lai, Robert M. Languedoc, Steve Lasley, Winser Lo, Naga Madipalli, Craig Main, Avinash Mandsaurwale, Thomas Mathai, S. Mehra, Yuan Meng, Simon Miller, William Moore, Anders Morch, George A. Murakami, Sandy Nemecek, Chun Pan, Abigail García Patiño, Anil Philip, Alfred Raouf, Peter Rorden, Christian Seifert, Gurpreet Singh, Christopher Stanwood, Swaminathan Subramanian, Siva Sundaram, Manju Swamy, John Sweeney, Harmon Taylor, Andrew Tolopko, Ravi Verma, Per J. Walstrøm, Chun Wang, James Ward, Winky, Chun Wang, Jimmy Yang, Jennie Yip, Yanqu Zhou, and Yingting Zhou.

At the UK office of Addison-Wesley/Pearson Education, we would like to thank our former editor Simon Plumtree for his unceasing support and patience while we slogged on with the second edition. We would also like to acknowledge the help and support of the following professionals, past and present, at the London office: Alison Birtwell, Sally Carter, Karen Sellwood and Katherin Ekstrom. A special thanks to Karen Mosman (who has since moved on to another job) for her encouragement and advice.

During the last lap of getting the book to the printing press, we were in the capable hands of Ann Sellers at the US office of Addison-Wesley/Pearson Education. We would like to acknowledge her efforts and that of other professionals—in particular, Greg Doench, Jacquelyn Doucette, Amy Fleischer, Michael Mullen, and Dianne Russell—who helped to get this book through the door and on to the bookshelf. Thanks also to Mike Hendrickson for always lending an ear when we met at the OOPSLA conferences, and pointing us in the right direction with our book plans.

We would like to thank the folks at Whizlabs Software for their collaboration in producing the contents for the CD accompanying this book. Those guys certainly know the business of developing exam simulators for certification in Java technology.

We were fortunate in having two Java gurus—Laurence Vanhelsuwé and Marcus Green—to do the technical review of the second edition. As he did for the first edition, Laurence came through and provided us with invaluable feedback, from the minutiae of writing technical books to many technical issues relating to the Java programming language. Marcus put the manuscript through his severe certification scrutiny regarding the specifics of the SCPJ2 exam. We are sorry to have upset their plans for Easter holidays, and hasten to thank them most profusely for taking on the task.

We cannot thank enough our own in-house, private copy-editor: Marit Seljeflot Mughal. She diligently and relentlessly read numerous drafts of the manuscript, usually at a very short notice. Marit claims that if she understood what we had written, then a computer-literate person should have no problem whatsoever. This claim remains to be substantiated. If any commas are not used correctly, then it is entirely our fault, in spite of being repeatedly shown how to use them.

We are also indebted to many Java-enabled individuals for providing us valuable feedback on parts of the manuscript for the second edition. This includes Pradeep Chopra, Seema R., and Gaurav Kohli at Whizlabs Software. Unfortunately for us, they only had time to read part of the manuscript. Thanks also to Torill Hamre at the Nansen Environmental and Remote Sensing Center, Bergen, for her useful comments and suggestions. We also thank the following Master students at the Department of Informatics, University of Bergen, for providing useful feedback: Mikal Carlsen, Yngve Espelid, Yngve A. Aas, Sigmund Nysæter, Torkel Holm, and Eskil Saatvedt.

Family support saw us through this writing project as well. Our families have put up with our odd and long working hours, endured our preoccupation and our absence at the dining table. Khalid would like to acknowledge the love and support of his wife, Marit, and daughters, Nina and Laila, while working on this book. Rolf would like to thank Liv, Rolf V., Knut, and Elisabeth for their love, patience and support.

—Khalid A. Mughal,
Rolf W. Rasmussen
March 2003
Bergen, Norway

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.16.166.113