About the Author
Read an Excerpt
Chapter 1: Java and the Sun Certification TestTerms you'll need to understand:
- Radio button
- Text entry question
- Assessing your exam-readiness
- Preparing based on the objectives
- Practicing, practicing, practicing
- Pacing yourself
- Not panicking
- Guessing in an informed manner
Assessing Exam-ReadinessI 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 TestI 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 http://java.sun.com/products/index.html.
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 ExamsA 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 www.jchq.net and the JavaRanch site at www.javaranch.com. 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 www.lanw.com/ 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 EnvironmentTests 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.
Question TypesQuestions 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.
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.
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
- c. The System.arraycopy method works only with arrays of
- 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.
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.
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
- Self-Assessment .....xxvii