- Shopping Bag ( 0 items )
New edition includes five bonus chapters on the Developer's Exam.200 hundred new, challenging practice questions, in the book and on the CD. The CD features a custom testing engine with practice programmer's exam.Includes strategies and tips for passing the exams- A Sample Developer's Assignment.
Your first goal in defining a good class should be to clearly state the operations that can be applied to instances of that class. Next, consider how to represent the state of the instance, keeping in mind that this should be done only with variables of private accessibility. All behavior should be accessed only via methods. By insisting that the variables inside an object are inaccessible outside the object, you ensure that the nature of those vari-ables is irrelevant outside the object. This in turn means that you can freely change the nature of the storage, for maintenance purposes, for performance improvement, or for any other reason.
Sometimes, perhaps as a consequence of the way you have stored the state in a class, boundary conditions must be applied to its methods. A boundary condition is a limit on the range of arguments for which a method can operate properly. As examples, a square-root function cannot operate conventionally on a negative number; an add operation cannot operate if both of its arguments are more than half the maximum representable range for the operation's return type.
When you encounter a boundary condition that results from your choice of storage format, you must make a choice. If you consider that the bound-ary conditions are reasonable, then you should do two things. First, docu-ment the boundary condition. Next, test the boundary conditions at the entry to the method and, if the boundary condition has been exceeded, throw a runtime exception of some kind. Alternatively, you might decide that the boundary condition is not acceptable, in which case you should redesign the storage used in the class.
Now, consider this: If you had allowed access to any of the variables used to represent the object state, then redefining the way the object's state is stored would immediately cause any other code that uses these variables to have to be rewritten. However, by using only private member variables, we have insisted that all interaction with this object is made through methods and never by direct variable access—so we have eliminated this problem. In consequence, we are able to redesign our internal storage freely and, provided the signatures of all the methods remain the same, no other code needs to change.
Sometimes you will realize that the methods you have provided for a class are inadequate. This is not usually a problem, either. You may add new methods to freely provide additional functionality. No client code will break, provided the methods that were already provided remain available, with the same signatures and the same semantics. The only issues that might arise during maintenance are if you realize that a method you have defined has a fundamentally flawed prototype. This should not happen often, since it implies that the operation you defined for the class was conceptually flawed in some way.
Encapsulation and Perceived EfficiencyMany programmers have such deep-seated concerns about performance that they cannot bring themselves to force all access to their objects to be made through methods, and they resist creating classes with entirely private member variables. There are several reasons why this is an unwise approach. First, fully encapsulated classes are more likely to be used correctly, especially if boundary conditions are properly flagged with excep-tions— therefore, code using them is more likely to be correct. Second, bug fixes and maintenance changes are less likely to break the program as a whole, since the effects of the change are confined to the affected class. These reasons fall into the broad heading of "Would your customer prefer a slow program that works and is delivered on time (and that can be made faster later) or a program that is delivered late, works incorrectly, but runs quickly?"
There are more reasons why fully encapsulated classes are the right way to start out a design. An optimizing virtual machine such as Sun's HotSpot can transparently optimize simple variable access methods by "inlining." This approach allows the program all the robustness, reliability, and maintain-ability that results from full encapsulation, while giving the runtime perfor-mance associated with direct variable access. Furthermore, if you decide that a program's slow performance is attributable to the use of private variables and accessor/mutator methods, then changing the variable to be more accessible does not require any changes to the rest of the code, either inside or outside the class. On the other hand, if you have code that fails to run properly as a result of making direct variable access, you will find that reducing the accessibility of the relevant variable will require considerable collateral changes in many other pieces of code (all code that makes such direct access).
Writing good, encapsulated classes usually requires more work in the initial stages than would have been required to produce the same functionality with a traditional programming approach. While this is true, you will normally find that using rigorous OO techniques will actually reduce the overall time required to produce finished code. This happens for two reasons. The first is that the robust classes you produce actually require less time to integrate into the final program and less time to fix bugs. The second is that with careful design you can reuse classes even in some circumstances that are different from the original intent of the class.
This reuse is actually possible in two ways, using either composition (the "has a" relation) or inheritance (the "is a" relation). Composition is probably safer and easier to control, although inheritance—perhaps because it is perceived as "pure OO"—seems to be more interesting and appealing to most programmers.
The Java certification exam does not require you to discuss details of object-oriented design techniques or the relative merits and weaknesses of composition versus inheritance. However, you should appreciate one significant sequence of facts: If a class is well encapsulated, it will be easier to reuse successfully. The more a class is reused, the better tested it will be and the fewer bugs it will have. Better-tested, less-buggy classes are easier to reuse. This sequence leads to a positive spiral of quality since the better the class, the easier and safer it becomes to reuse. All this comes from tight encapsulation.
Now that we've discussed why you would want to write object-oriented code, let's look at how this is achieved....
|Pt. I||The Programmer's Exam||1|
|Ch. 1||Language Fundamentals||3|
|Ch. 2||Operators and Assignments||29|
|Ch. 4||Converting and Casting||99|
|Ch. 5||Flow Control and Exceptions||127|
|Ch. 6||Objects and Classes||163|
|Ch. 8||The java.lang and java.util Packages||233|
|Ch. 9||Layout Managers||259|
|Ch. 13||Input and Output||375|
|Pt. II||The Developer's Exam||403|
|Ch. 14||Taking the Developer's Exam||405|
|Ch. 15||Assignment: Room Reservation System||419|
|Ch. 16||Enhancing and Extending the Database||433|
|Ch. 17||Writing the Network Protocol||461|
|Ch. 18||Designing the User Interface||501|
|Ch. 19||Thinking about the Follow-Up Exam||531|
|App. A: Answers||547|
|App. B||Using the Test Program||575|
|App. C||Java 2 API Reference||583|
You have come here because you are ready. Ready to get ready, at least, which is practically the same thing. Now all that's left to do is the work.
And there is a lot of work to be done. Probably you heard that the 1. 1 version of the exam was difficult. That was true; the Java 2 version is harder still, since it covers a few more topics. Not everybody passes--even on repeated attempts. We want to change these statistics. It wouldn't hurt to get a little help--and we're the ones to help.
Since this is, after all, the Introduction, allow us to introduce ourselves: Simon, Mike, and Phil. We are Java instructors by day, and by night we write.
What we teach (by day) are Sun Microsystems' Java courses. When the 1.1 edition of this book was published, we wrote that among us we had taught Java to more than 1,000 people. By now the number is well into the thousands. And the Java courses that we teach are Sun's own courses. We have been through our own certification process for instructors, and Sun trusts us to teach people the Java facts that Sun considers important. Recently, Simon has been developing new course material. We want you to know all this because we want to be the ones to help you pass the certification exam.
What we write (by night) are Java books. (Phil keeps talking about a novel; we will just have to wait and see.) We wrote the Java 1. 1 Developer's Handbook (Sybex, 1997) and we contributed to Mastering Java 1. 1 (Sybex, 1997). Then we wrote the Java 1. 1 Certification Study Guide.After that we revised the Developer's Handbook to reflect new Java 2 material. And now here we are, presenting the Java 2 version of the Certification Study Guide.
We thought we were the best team to write this book. Simon led the team that wrote all of the questions for the exam. Phil was a consultant for developing the exam and is one of the graders for the developer's exam, so he also has the inside view of things. And Mike, who wrote the chapters about the developer's exam, has been on the front lines of Java instruction for years.
Simon's unique position at Sun places a few restrictions on us. We can't give away any answers to the questions on the exam. (We wouldn't want to do that anyway; we want you to pass because you're good at Java, not because we slipped you a crib.) We had to make sure that the sample questions did not accidentally match any of the real test questions. It took a bit more work, but we think the benefit to you is tremendous: Everything in this book is here for a very good reason. If it's here, then it's here because we know you need to know about it. We understand that buying a book like this costs you money, reading it costs you time, and absorbing it costs you effort. We appreciate your investment and we believe it will pay off.
If you read this book, absorb it, solve the practice questions at the end of each chapter, and work through the practice exam on the CD-ROM, you will be in the best possible position when you walk through the doors of your local testing center.
Let's just take care of a few standard formalities and then we can really get started.
What's New in This Edition
The original edition of this book covered the 1. 1 version of the programmer's exam. When Sun released Java 2, they also released new versions of both the programmer's exam and the developer's exam, along with corresponding lists of study objectives.
There were more than 90 objectives for the 1.1 programmer's exam; that number has been reduced for Java 2 to about 30. The huge reduction doesn't mean that the exam is simpler; it just means that redundant objectives have been combined or eliminated. We have stayed with the format that we introduced in the original edition of this book: a chapter begins with a list of the objectives covered in the chapter. All of the objectives appear at least once, so if you master each chapter, you will have mastered all of the objectives.
So, our first change was to introduce the new Java 2 material. We also thought it would be appropriate to upgrade the test engine. The sample questions at the end of each chapter are for the most part unchanged, because we originally designed those questions to teach you as much as possible. The original questions were very well accepted, so we stayed with them, but we made two additions. First, of course, we added questions to cover the new Java material as reflected in the new objectives. Second, we added many new questions to the test engine on the CD-ROM that accompanies this book. Please refer to Appendix B for information on how to use the test engine.
If you are intrigued by the idea of sample questions, here is a sample of the samples:
3. Which of the following statements is true?A. An abstract class may not have any final methods.
B. A final class may not have any abstract methods.
Here is a typical code-related question:
3. Will the following code compile?1. byte b 2;
2. byte b1 3;
3. b = b * b1
Feel free to look up the answers in Appendix A. The first question is #3 from Chapter 3; the second question is #3 from Chapter 4.
The other big change was to include an extensive new section on the Java Developer's Exam. We received a lot of feedback from readers who said that they were interested in complete certification, not just programmer certification. So Mike was brought in to write about developer certification. We can't tell you what your developer's assignment will be (any more than we can tell you about questions on the programmer's exam); but we have given you a similar problem, one that can serve as a metaphor and that requires you to master the same skills that you will need for the real exam.
We hope that the Java 2 edition of this book will be all you need to catapult you into both programmer and developer certification.
Taking the Exam
You can take the Java Certification Exam whenever you like, by making an appointment with Sylvan Prometric or Sun Educational Services. Sylvan Prometric administers the exam on Sun's behalf; they have test centers throughout the world, so hopefully you won't have to travel far. The cost of taking the exam is $150.
Note: The telephone number for Sylvan Prometric is 800-795-EXAM; their URL is www.sylvanprometric.com. The number for Sun Educational Services is 800-422-8020; their URL is www.sun.com/sunservice/suned/certif_ programs.htmI. For people outside the United States, information on registration in any of the eighty-eight countries that Sylvan services is available at this site: www.hibbertco.com/sun/suncontacts/contacts.html.
You can make an appointment any time during regular business hours. You will be given two hours and fifteen minutes and you will probably need every minute. You will not be allowed to bring food or personal belongings into the test area. One piece of scratch paper is permitted; you will not be allowed to keep it after you have finished the exam. (See the end of Chapter 9, "Layout Managers," for a suggestion about how to use the scratch paper.) Most sites have security cameras.
You will be escorted to a cubicle containing a PC. The exam program will present you with randomly selected questions. Navigation buttons take you to the next question or to previous questions for review and checking. When you have finished the test, the program will immediately present you with your score and a pass/fail indication. You will also be given feedback that indicates how well you performed in each of the dozen or so categories of the objectives. You will not be told which particular questions you got right or wrong.
Formalities of the Exam
There are no trick questions on the exam, but every question requires careful thought. The wording of the questions is highly precise; the exam has been reviewed not just by Java experts, but also by language experts whose task was to eliminate any possible ambiguity. All you have to worry about is knowing Java; your score will not depend on your ability to second-guess the examiners.
It is not a good idea to try to second-guess the question layout. For example, do not be biased toward answer C simply because C has not come up recently. The questions are taken from a pool and presented to you in a random order, so it is entirely possible to get a run of a particular option; it is also possible to get the answers neatly spread out.
Most of the questions are multiple choice. Of these, some have a single answer while others require you to select all the appropriate responses. The Graphical User Interface of the test system indicates which kind of answer you should supply. If a question only has one correct answer, you will be presented with radio buttons, so that selecting a second answer cancels the selection of a previous answer. With this kind of question, you have to select the most appropriate answer. If, on the other hand, you are presented with check boxes, then you may need to make more than one selection, so every possible answer has to be considered on its own merits-not weighed against the others.
You should be aware that where multiple answers are possible, you are being asked to make a decision about each answer, rather as though the question were five individual true/false questions. This requires more effort and understanding from you, but does not actually mean that more than one answer is correct. Think carefully, and always base your answer on your knowledge of Java.
The short-answer, type-in questions often cause undue concern. How are they marked? What happens if you omit a semicolon? These worries can stem from the knowledge that the questions are marked electronically and the belief that an answer might be marked wrong simply because the machine didn't have the sense to recognize a good variation of what it was programmed to accept.
As with all exam questions, you should be careful to answer precisely what is asked. However, you should also be aware that the system does accept a variety of different answers; it has been set up with all the variations that the examination panel considered to be reasonable.
Some of the type-in questions provide specific instructions concerning the format of the answer. Take this guidance seriously. If, for example, a question says, "Answer in the form methodname(), " then your answer should be
and not any of these answers
Some of the other answers might well be accepted, but programming is a precision job and you should be accustomed to following precise directions.
The test is taken using a windowed interface that can be driven almost entirely with the mouse. Many of the screens require scrolling; the scroll bar is on the right-hand side of the screen. Always check the scroll bar so you can be sure you have read a question in its entirety. It would be a shame to get a question wrong because you didn't realize you needed to scroll down a few lines.
The exam contains about 60 questions. On average, this gives you a little more than two minutes per question. Some of the questions are easier than others, and undoubtedly there will be some that you can answer faster than others. However, you really do need to answer all the questions, if you possibly can. The test system allows you to review your work after you reach the end. The system will explicitly direct your attention toward any multiple choice questions that have no items selected. So if you find a particular question difficult, consider moving on and coming back to it later.
If you pass, you will be given a temporary certificate. A few weeks later you will receive by mail a permanent certificate, along with an artwork sheet. The artwork shows the "Sun Certified Java Programmer" logo at various magnifications. By passing the exam, you have earned the right to display the logo. Printers know how to reproduce the artwork onto business cards, stationery, and so on. The lettering is legible (just barely, by people who eat carrots) down to a reduction of about 5/8 " wide by 3/8 " high.
Posted November 13, 2002
I have read this book and I think that this is a good start toward the certification, the book covers alot of topics in a simple easy to understand and memories way, this is an in-bridth coverage rather to be in-depth one, yet it is vey good for the exam.Was this review helpful? Yes NoThank you for your feedback. Report this reviewThank you, this review has been flagged.
Posted February 13, 2002
This book isn't what I expected. Its full of errors and inconsistencies. Did anyone proofread? I had trouble with the code in many places. Overall I came away wondering if the authors knew what they were doing.Was this review helpful? Yes NoThank you for your feedback. Report this reviewThank you, this review has been flagged.
Posted January 10, 2002
This is a great book. Everything you need to know is covered and explained. The sample exams are excellent. I scored mid 70's on the sample exams and also on the real exam.Was this review helpful? Yes NoThank you for your feedback. Report this reviewThank you, this review has been flagged.
Posted December 22, 2000
This is an excellent book to prepare yourself for the Programmers Exam. I'm an undergrad with no experience; took a Java class and studied from this book and PASSED the exam. I learned a lot of things (from this book) about the Java Language that my undergraduate Java class didnt teach me.Was this review helpful? Yes NoThank you for your feedback. Report this reviewThank you, this review has been flagged.
Posted October 16, 2000
This book is an excellent material for the preparation of Java Programmer Certificaiton. The recommended reader level for this book is Intermediate/Advanced ; hence the beginners, should study some other entry level book, before they start reading this book. The test at the end of each topic and their answers at the end of the book are comprehensive and are adequete to build a good understanding level for the readers.Was this review helpful? Yes NoThank you for your feedback. Report this reviewThank you, this review has been flagged.
Posted October 14, 2000
I study Java 2 from other books and bought this book so I could check how well I am doing. This book is excellent for that purpose. I am not studying for either of the exams (Programmer's or Developer's) but this book is very valuable. The first 400 pages are about the programmer's exam. Each chapter is about one objective and in the end you can take a full mock test about the whole area. This first part is what I use frequently to test my skills and knowledge. The rest of the book is not so precise, for the Developer's exam is not about multiple choice questions. This part has articles about how a sample problem, similar to those in the exam, is solved apropriately. If you are studying Java 2 and need a way to keep sure that you are learning what the trade and business needs, this book is an excellent companion.Was this review helpful? Yes NoThank you for your feedback. Report this reviewThank you, this review has been flagged.