Java 2 Exam Cram, Second Edition

Java 2 Exam Cram, Second Edition




Java 2 Exam Cram, 2nd Edition is the updated and revised version of the best selling Java 2 Exam Cram. This highly acclaimed and well-recognized study guide provides an intense preparation program for programmers gearing up for the Sun Certified Java Programmer, Java 2 exam (310-025). The book's well organized, concise layout provides thorough coverage of test content and objectives like learning Java language fundamentals, creating Java classes, building GUIs with the AWT Components, and working with flow control and exceptions. Includes the proven Exam Cram features of helpful hints and tips, test taking strategies, realistic case studies, tear-out cram sheets, and challenging practice questions.

Product Details

ISBN-13: 9781588801395
Publisher: Coriolis Value
Publication date: 07/16/2001
Series: Exam Cram 2 Series
Edition description: 2ND
Pages: 448
Product dimensions: 6.04(w) x 9.02(h) x 1.12(d)

About the Author

Bill Brogden (Austin, Texas) is a full time programmer and author with over 20 years of experience. Bill is an expert in several programming languages and currently focuses on the Java language, of which he has written five books. He has also developed the script-driven Java-based architecture for LANWright's online course delivery engines that is used to provide practice tests on a wide range of subjects.

Read an Excerpt

Chapter 1: Java and the Sun Certification Test

Terms you'll need to understand:
  • Radio button
  • Checkbox
  • Text entry question
Techniques you'll need to master:
  • Assessing your exam-readiness
  • Preparing based on the objectives
  • Practicing, practicing, practicing
  • Pacing yourself
  • Not panicking
  • Guessing in an informed manner
This book is intended to prepare you for taking and passing the Sun Certified Programmer for the Java 2 Platform exam. In this chapter, I cover the way the test is administered, suggestions for test-taking strategy and tactics, how to prepare for the test, and a short history of the various versions of the Java language. Subsequent chapters explore various aspects of Java that are likely to appear on the test or are essential to understanding the Java programming language. This book is not intended to cover all aspects of Java; that task takes a whole bookshelf these days.

Assessing Exam-Readiness

I strongly recommend that you read through and take the Self-Assessment in-cluded with this book (it appears just before this chapter, in fact). This will help you compare your knowledge base to the requirements for passing the Sun Certified Programmer exam, and it will help you identify parts of your background or experience that may be in need of improvement, enhancement, or further learning. If you get the right set of basics under your belt, obtaining Sun certification will be that much easier.

Once you've worked through the Exam Cram, have read the supplementary ma-terials as needed, and have taken the practice test, you'll have a pretty clear idea of when you should be ready to take the real exam. The practice test included in this book is considered slightly harder than the real one. We strongly recommend that you keep practicing until your scores top the 70 percent mark; 75 percent would be a good goal, to give yourself some margin for error in a real exam situation (where stress will play more of a role than when you practice). Once you hit that point, you should be ready to go. But if you get through the practice exam in this book without attaining that score, you should keep taking the practice test and studying the materials until you get there.

Preparing for the Test

I feel that it will be very helpful for you to have available a working copy of Java Development Kit ( JDK) 1.2 or 1.3. As of this writing, the only source is the Sun Web site at

The total installation file is over 20MB, but you can download it in pieces if necessary. It takes a huge amount of disk space to install�over 65MB after you have the installation file downloaded, so clean out your hard disk. You can also download the JDK documentation, which is very complete but also very bulky.

Naturally, you should practice with the questions at the end of each chapter and the practice test in Chapter 15. There are also a fair number of Web sites devoted to preparation for the Java 2 programmer certification exam. I've listed some in the "Just the FAQs" section later in this chapter, but more will probably appear, so try a Web search engine.

Practicing with Mock Exams

A number of practice tests other than the one in this book are available on the Web. I recommend Marcus Green's Java Programmer Certification Page at and the JavaRanch site at Both of these sites also have tutorials and discussion groups that can help you prepare for the exam.

Finally, I will be maintaining and adding to the mock exam at java/javacert. I used this practice test to evaluate sample questions for this book and to locate topics that most new Java programmers have a hard time with.

Write! Write! Write!

Finally, and I can't emphasize this enough, write lots of code. I keep seeing questions that ask whether a piece of code will compile or run in online discussion groups. You can decide the answers to these questions in a few minutes by writing a simple Java class. If you get compiler or runtime errors, learn from them.

The Test Environment

Tests are administered by the Prometric organization using typical Windows-based computers. You will be in a quiet environment with one or more testing stations in a separate room. Typically, this room will have a large picture window that enables the test coordinator to keep an eye on the test takers to make sure people are not talking to each other or using notes. Naturally, you are not allowed to take any notes into the room.

There will be scratch paper or an erasable plastic sheet with a felt tip marker. You can use this to write down key information; however, you are not allowed to take any notes out of the exam. If there is any topic you have a hard time remembering, you might want to scan the Cram Sheet from the front of this book just before taking the test and then make a few quick notes when you get into the testing room.

The computer will be a pretty typical system with mouse and keyboard. The initial screen gives you the option to run a quick tutorial test. If you have never taken one of these tests before, you should take the tutorial. The real test timer does not start until you have specifically chosen to start the real test.

As of this writing, you are allowed 120 minutes to answer 61 questions, of which 59 are for the certification and 2 are related to Sun's privacy policy. This is plenty of time if you have studied the material. I have to say "as of this writing" because in earlier versions of the test, only 90 minutes were allowed, and Sun may change again.

Question Types

Questions are presented on the screen in a scrollable window. There are three styles of questions:
  • Multiple choice with radio buttons�This type of question presents a number of possible choices labeled with lowercase letters and presented with a round radio-style button. You can answer by either clicking the button with the mouse or typing the letter on the keyboard. Only one item can be chosen.

  • Multiple choice with checkboxes�In this type of question, the number of correct answers may vary from one to all of them. To indicate this, you will be presented with square checkboxes instead of radio buttons. As of the October 2000 version of the test, the question text includes the number of correct answers, so all you have to do is select the correct ones. Because Sun may revert to the earlier style that did not give this hint, I suggest that you not rely on it. All correct answers must be checked for you to get any credit for the question; no partial credit is awarded for partially correct selections.

  • Text entry questions�This type of question presents a one-line text area for you to type the answer. Pay close attention to what the question is asking for so you don't type more than what it wants. For example, do not enclose your text in quotation marks unless the answer specifically requires them. In most cases, a list of possible words is presented as part of the question, so what you have to do is select the correct words and type them in the right order. Remember that Java is case sensitive.
Questions that require presentation of more than about eight lines of code will provide an Exhibit button to pop up a separate scrollable window that shows the code. The purpose of this is to let you see the option text and question text as close together as possible. Don't be too eager to see the code; read the question and the options first so you will know what to look for.

Here is a sample multiple-choice question that requires you to select a single correct answer. Following the question is a brief summary of each potential answer and why it is either right or wrong.

Question 1

Here are some statements about the java.lang.System class. Which of the following statements is correct?

  • a. You must initialize System with a path and file name if you want to use the System.err output.
  • b. The System.timer method allows timing processes to the nearest microsecond.
  • c. The System.arraycopy method works only with arrays of primitives.
  • d. The System.exit method takes an int primitive parameter.

Answer d is correct. The System.exit method takes an int primitive value that can be used as an error code returned to the operating system (OS). Answer a is incorrect because the System.err print stream is automatically created by the Java Virtual Machine ( JVM). Answer b is incorrect because there is no System.timer method and the System method that does return the time is precise only to the millisecond. Answer c is incorrect because System.arraycopy works with both primitive and reference arrays.

Let's examine a question that requires choosing multiple answers. This type of question provides checkboxes rather than radio buttons for marking all appropriate selections.

Question 2

Which of the following statements about the java.util.Vector and java. util.Hashtable classes are correct? [Check all correct answers]

  • a. A Vector can hold object references or primitive values.
  • b. A Vector maintains object references in the order they were added.
  • c. A Hashtable requires String objects as keys.
  • .d. A Hashtable maintains object references in the order they were added.
  • e. Both Vector and Hashtable use synchronized methods to avoid problems due to more than one Thread trying to access the same collection.
Answers b and e are correct. A Vector maintains the order in which objects are added but a Hashtable does not. Answer e is true�Vector and Hashtable use synchronized methods. Answer a is incorrect because a Vector can hold only references, not primitives. If you need to store primitive values in a Vector, you must create wrapper objects. Answer c is incorrect because any object may be used as a Hashtable key (although Strings are frequently used). Answer d is incorrect because a Vector maintains the order in which objects are added but a Hashtable does not....

Table of Contents

Introduction ..... xxi
Self-Assessment .....xxvii
Chapter 1: Java and the Sun Certification Test ..... 1
Chapter 2: Language Fundamentals ..... 13
Chapter 3: Java Operators with Primitives and Objects ..... 31
Chapter 4: Creating Java Classes ..... 63
Chapter 5: Nested Classes ..... 85
Chapter 6: Converting and Casting Primitives and Objects ..... 105
Chapter 7: Flow Control and Exceptions ..... 127
Chapter 8: Working with Java Classes and Objects ..... 157
Chapter 9: Java Threads ..... 177
Chapter 10: Standard Library Utility Classes ..... 201
Chapter 11: Java AWT Components ..... 225
Chapter 12: Building Graphical Interfaces with the AWT Components ..... 251
Chapter 13: The Java Event Model ..... 273
Chapter 14: Java IO ..... 297
Chapter 15: Sample Test ..... 323
Chapter 16: Answer Key ..... 365
Glossary ..... 379
Index ..... 401

Customer Reviews