Home > Store

Java FAQ, The

Register your product to gain access to bonus material or receive a coupon.

Java FAQ, The

Book

  • Sorry, this book is no longer in print.
Not for Sale

Description

  • Copyright 1997
  • Edition: 1st
  • Book
  • ISBN-10: 0-201-63456-2
  • ISBN-13: 978-0-201-63456-3

This book provides an insider's view of the Java technology by posing and answering the most important, frequently asked questions about the Java programming language, Java applets, and Java stand-alone applications. The Java FAQ is unique in that it draws from the tens of thousands of questions sent to java@java.sun.com and provides authoritative answers direct from the creators of the Java programming language at JavaSoft.

Presented in a handy question-and-answer format, The Java FAQ contains over 200 of the most important and informative of these questions together with concise explanations and creative solutions. The book is a powerful reference that can quickly help you over common stumbling blocks. Representing the collective wisdom of the JavaSoft team, it is an excellent resource for design tips, practical examples, style guidelines, insightful explanations, and insider information that will save you time and improve the quality of your Java programming.

The questions encompass the gamut of Java topics: objects, classes, methods, interfaces, exceptions, arrays, the virtual machine, applets, AWT components and containers, layouts, events, images, threads, sockets, and more. Well indexed and thoroughly cross-referenced, the book enables you to quickly locate precisely the information you need.

Appropriate for Java programmers of all levels, The Java FAQ includes clearly worded explanations to fundamental questions, such as:

  • What is an applet?
  • How do applets differ from applications?
  • Does the Java language allow multiple inheritance?
  • How do I create an instance of a class?

Experienced Java programmers will benefit from pointed answers to more sophisticated questions, including:

  • How can I accomplish the equivalent of function pointers in Java, for instance, for use in an array?
  • How can I arrange for different applets on a web page to communicate with each other?
  • Do events propagate in the JDK 1.1 as they did in the older AWT event model?
  • How do the wait and notifyAll/notify methods enable cooperation between threads?
  • When will I be able to create a broadcast datagram packet?



0201634562B04062001

Sample Content

Table of Contents



Preface.


1. Classes, Interfaces, and Packages.

Objects, Classes, and Methods.

Subclassing, Overloading, and Overriding.

Interfaces and Abstract Classes.

Packages and Access Modifiers.



2. Java Language.

Constants and Expressions.

Variables and Methods.

Arrays.

Exceptions.



3. Virtual Machine.


4. Applets.

Applets versus Applications.

Installing Applets.

Applet User Interface.

Applet Program Structure.

Applet Communication.

Miscellaneous.



5. Abstract Window Toolkit.

Components, Containers, and Peers.

Windows, Frames, and Dialogs.

Miscellaneous.



6. Events-JDK 1.0.2.


7. Events-JDK 1.1.

Event Classes, Listeners, and Methods.

Semantic Events.

Low-level Events.



8. Drawing.

Drawing AWT Components.

Loading and Drawing Images.

Images-JDK 1.0.2.

Images-JDK 1.1.



9. Threads.

Creating and Controlling Threads.

Thread Interactions.

User Threads versus System Threads.



10. Input, Output, and Network.

Basic Input and Output.

URL Connections.

Internet Addresses.

Sockets.



11 Miscellaneous.

Classes in java.lang and java.util.

Audio.

Miscellaneous.



Index. 0201634562T04062001

Preface

Java technology has achieved remarkably widespread use in a very short time. The broad acceptance of Java reflects Java's technical strengths and feature set: platform-neutrality, dynamism, object-orientation, garbage collection, security, concurrency, robustness, and Internet savvy. The Java language has established itself as a mature, general-purpose programming language, and the standard Java class libraries provide an ever-broadening platform supporting a wide spectrum of application development.

Nevertheless, the speed and passion with which many developers have adopted Java shows that more than just technical soundness is at work. Java is fun to use and practical. It removes tedious and error-prone parts of application development such as memory management and cross-platform porting. It allows the developer to focus more energy on program design and functionality. The language is also comparatively easy to learn, thanks to a strong principle that guided the creation of Java: "Keep it simple!" An important corollary to this principle is: "Keep it learnable!" Java is not only fun to use but also fun to learn.

This book is a tool for developers learning to use Java. Its primary goals are unabashedly pragmatic:

  • to provide easy access to highly relevant information
  • to avert or debug common misunderstandings and errors
  • to give you the information you need in a form you can use

The Java FAQ is not a fully detailed treatise on Java technology-for this, see The Java Language Specification, The Java Virtual Machine Specification, or one of the API reference books in the Java Series. Nor is it a carefully guided, sequenced exposition of Java-for this, see The Java Programming Language or The Java Tutorial.

This book, by means of its frequently asked-question (FAQ) format, takes direct advantage of a teacher's two favorite tools, questions and examples. Questions specify an informational need: if you can spell out what information you are missing, you are more than halfway towards attaining it. A question sets the context for linking new information into existing knowledge; it establishes the relevance (or usefulness) of the information.

Examples, likewise, give a penetrating edge to information. A specific example is usually easier to grasp than the general idea it illustrates. Sample code, moreover, is an especially useful form of example, since it can often be built into larger, working programs.

What qualifies as a frequently asked question? The primary source of questions for this book was the e-mail traffic at the java@java.sun.com address. This e-mail address was the default technical support pipeline for Java technology, especially in the formative period when Java and HotJava were progressing from a 1.0 alpha release, to beta, and finally to FCS (First Customer Ship). Although the term frequently asked questions suggests a collection of the most common questions (plus answers), this book has a slightly different target: frequently ask-worthy questions, that is, the questions you need to have answered in order to learn Java quickly and use it effectively. The Java FAQ aims for the question behind the question: the more general information gap or misunderstanding that, when filled or corrected, can answer a host of more specific questions. When you ask a question, it is important to know if your question has been answered. Thus, this book follows the admirable example set by The C++ FAQs (by Cline and Lomow, Addison-Wesley, 1995) of providing a highlighted short answer immediately following each question. This gives the answer in a nutshell, and the rest of the answer then explains and exemplifies the nutshell answer.

Many answers end in a pointer in the form of a partial URL (Uniform Resource Locator), such as GrabPixelsExample.html. These pointers refer to web pages containing sample code, applets, or other example material related to the answer. You can access these web pages by following links starting from the Java Series home page at the JavaSoft web site: http://java.sun.com/Series.

Each question-answer pair is intended to stand on its own as far as possible, but numerous cross references are included to indicate connections or dependencies in the material. You can dive into the middle of the book and follow leads from there, or you can start at the beginning and read straight through.

The Java FAQ covers the Java language, the Java Virtual Machine, and the standard classes in the following packages: java.lang, java.applet, java.awt, java.awt.image, java.awt.event, java.io, java.net, and java.util. This is essentially the contents of Sun's Java Devloper's Kit (JDK) 1.0 release together with updated information for the JDK 1.1 release. Information and sample code specific to one or another release is flagged explicitly throughout the book: "JDK 1.0.2" for the version most widely deployed during the span of this book's writing and "JDK 1.1" for the family of releases from JavaSoft in the first half of 1997 (JDK 1.1, 1.1.1, and 1.1.2). Packages representing wholly new functionality added in the JDK 1.1, such as java.rmi, java.beans, and java.security, are not covered.

This book would not have been possible but for the professional and personal assistance of many fine people at JavaSoft and elsewhere. Lisa Friendly first conceived of the book and encouraged me to take it on. Her patient yet persistent care as series editor helped me stick out this large project to the end. Carla Schroer graciously allowed me to take on the commitment despite other duties that were already claiming more than 100 percent of my time. Mary Aline's detailed edits of several early draft chapters reminded me to keep the writing clear, simple, and pleasantly grammatical. Mary Campione, Eric Chu, Jazmin Ellis, Doug Kramer, Nancy Lee, Rick Levenson, Marvin Ma, Ron Mandel, Freeman Murray, Scott Rautmann, Richard Scorer, Greg Voss, and Kathy Walrath added that nice human touch to my work environment, improving the quality of both my work time and my break time. For technical assistance with wide-ranging material, I am indebted to Tom Ball, Dave Brown, Patrick Chan, Dave Connelly, Jeff Dinkins, Pavani Diwanji, Amy Fowler, Jim Graham, Jeannette Hung, Herb Jellinek, Tim Lindholm, Marianne Mueller, Tim Prinzing, John Rose, Georges Saab, Nakul Saraiya, Sami Shaio, Arthur van Hoff, Chris Warth, and Frank Yellin. It was a delight to work with and learn from such a talented group of engineers. At Addison Wesley, Mike Hendrickson, Katie Duffy, Marina Lang, and Simone Payment made the difficult process of book development as sane as possible. Their good humor, hard work, and courteous professionalism go beyond the call of duty. Addison Wesley's manuscript reviewers and proofreaders considerably improved the book by their detailed comments and constructive criticism. In the later stages of the game, Vicki Hochstedler helped me navigate the joys and agonies of putting the book into final format, and Rosemary Simpson pulled together a painstaking and powerful index.

Above all, I am indebted to my family, who understand the demands of a normal job but gave up far more because of this book. My wife, Jean, is a gem. Her intelligence, honesty, thoughtfulness, and dead-on knack for the essential have been a cornerstone of my life and work for fifteen years. Thanks to her, I hope this book has not just content, but spirit. Our children, Kirsti, Silva, and Justin, are potent lessons in the value, challenge, and joy of life. Getting more time again to grow and play with them was special motivation for me to bring this project to conclusion. The household had one frequently asked question that couldn't be answered until the very end: "When will the book be done?" Well, the answer to that is finally, happily, at hand.

Jonni Kanerva
Mountain View, California
June, 1997



0201634562P04062001

Updates

Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020