This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com [ Team LiB ] • • • Table of Contents Index Examples Java 2™ Programmer Exam Cram™ (Exam CX-310-035) By Bill Brogden, Marcus Green Publisher: Que Pub Date: March 07, 2003 ISBN: 0-7897-2861-3 Pages: 416 This exam measures the ability to design, write, and understand programs written in language version 1.4 of the Java Platform The programmer's exam concentrates on the language basics This book is not intended to teach new material Instead it assumes that you have a solid foundation of knowledge but can use a refresher on important concepts as well as a guide to exam topics and objectives This book focuses exactly on what you need to pass the exam - it features test-taking strategies, time-saving study tips, and a special Cram Sheet that includes tips, acronyms, and memory joggers not available anywhere else The series is supported online at several Web sites: examcram.com, informit.com, and cramsession.com [ Team LiB ] This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com [ Team LiB ] • • • Table of Contents Index Examples Java 2™ Programmer Exam Cram™ (Exam CX-310-035) By Bill Brogden, Marcus Green Publisher: Que Pub Date: March 07, 2003 ISBN: 0-7897-2861-3 Pages: 416 Copyright A Note from Series Editor Ed Tittel About the Authors About the Technical Editors Acknowledgments We Want to Hear from You! Objectives Map Introduction Whom Is This Book For? Sun's Java Certifications Signing Up to Take the Exam About This Book How to Use This Book Self-Assessment Java in the Real World The Ideal Programmer Certification Candidate Assessing Your Readiness I Think I'm Ready, So What's Next? Chapter Java and the Sun Certification Test Introduction Assessing Exam-Readiness Preparing for the Test The Test Environment The Test Objectives What Happens When You Pass? Study Resources Notes on Java's History This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com Notes on Java's History Chapter Language Fundamentals Introduction Structure of Java Programs Java Reserved Words and Keywords Identifiers The Java Interpreter and the JVM Variables and Data Types in Java Arrays Program Conventions Using Java Tools and Documentation Exam Prep Practice Questions Need to Know More? Chapter Java Operators with Primitives and Objects Introduction Using Literals Numeric Operators String Objects and the + Operator Bitwise and Logical Operators Testing Object Equality Array Initialization Exam Prep Practice Questions Need to Know More? Chapter Creating Java Classes Introduction Defining a Class Class Members Interfaces Exam Prep Practice Questions Need to Know More? Chapter Nested Classes Introduction Nested and Inner Classes Static Nested Classes Accessing Nested Classes from Outside Exam Prep Practice Questions Need to Know More? Chapter Converting and Casting Primitives and Objects Introduction Converting and Casting Primitives Converting and Casting Reference Types Exam Prep Practice Questions Need to Know More? Chapter Flow Control Introduction Boolean Expressions No goto in Java Flow Control The if-else Structure The switch-case Structure The for Loop Structure Using while and Exam Prep Practice Questions Need to Know More? This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com Chapter Exceptions and Assertions Introduction Exceptions Using Assertions Exam Prep Practice Questions Need to Know More? Chapter Working with Java Classes and Objects Introduction Object-Oriented Design Overloading and Overriding Object Garbage Exam Prep Practice Questions Need to Know More? Chapter 10 Java Threads Introduction Thread Background The Thread Class Synchronizing Threads Exam Prep Practice Questions Need to Know More? Chapter 11 Standard Library Utility Classes Introduction Utility Classes in the java.lang Package The java.math Package The Reflection Package Utility Classes in the java.util Package Exam Prep Practice Questions Need to Know More? Chapter 12 The Collection Classes The Original Collections The New Collections Collections New with JDK 1.4 Exam Prep Practice Questions Need to Know More? Chapter 13 Sample Test One Practice Exam Chapter 14 Answer Key for Sample Test One Chapter 15 Sample Test Two Chapter 16 Answer Key for Sample Test Two Appendix A List of Resources Official Java Resources from Sun Microsystems Java Developer's Connection The Official Java Certification Site The Authors' Sites Web Sites with Exam-Related Resources Web Sites with General Resources Appendix B List of Products, Vendors, and Technologies Exam Simulators Books Appendix C What's on the CD-ROM The PrepLogic Practice Exams, Preview Edition An Exclusive Electronic Version of the Text This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com Appendix D Using the PrepLogic Practice Exams, Preview Edition Software The Exam Simulation Software Requirements Installing PrepLogic Practice Exams, Preview Edition Removing PrepLogic Practice Exams, Preview Edition, from Your Computer Using PrepLogic Practice Exams, Preview Edition Contacting PrepLogic License Agreement Glossary Index [ Team LiB ] This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com [ Team LiB ] Copyright Copyright © 2003 by Que Certification All rights reserved No part of this book shall be reproduced, stored in a retrieval system, or transmitted by any means, electronic, mechanical, photocopying, recording, or otherwise, without written permission from the publisher No patent liability is assumed with respect to the use of the information contained herein Although every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions Nor is any liability assumed for damages resulting from the use of the information contained herein Library of Congress Catalog Card Number: 2003100810 Printed in the United States of America First Printing: March 2003 04 03 02 01 Trademarks All terms mentioned in this book that are known to be trademarks or service marks have been appropriately capitalized Que cannot attest to the accuracy of this information Use of a term in this book should not be regarded as affecting the validity of any trademark or service mark Warning and Disclaimer Every effort has been made to make this book as complete and as accurate as possible, but no warranty or fitness is implied The information provided is on an "as is" basis The author and the publisher shall have neither liability nor responsibility to any person or entity with respect to any loss or damages arising from the information contained in this book or from the use of the CD or programs accompanying it Credits Associate Publisher Paul Boger Executive Editor Jeff Riley Acquisitions Editor Carol Ackerman Development Editor Susan Brown Zahn Managing Editor Charlotte Clapp Project Editor Tricia Liebig Copy Editor Kezia Endsley Indexer Ken Johnson Proofreader This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com Proofreader Juli Cook Technical Editors Steve Heckler Ger Button Team Coordinator Pamalee Nelson Multimedia Developer Dan Scherf Interior Designer Gary Adair Page Layout Cheryl Lynch Michelle Mitchell Graphics Tammy Graham [ Team LiB ] This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com [ Team LiB ] A Note from Series Editor Ed Tittel Que Certification • 201 West 103rd Street • Indianapolis, Indiana 46290 You know better than to trust your certification preparation to just anybody That's why you, and more than two million others, have purchased an Exam Cram book As Series Editor for the new and improved Exam Cram series, I have worked with the staff at Que Certification to ensure you won't be disappointed That's why we've taken the world's best-selling certification product—a finalist for "Best Study Guide" in a CertCities reader poll in 2002—and made it even better As a "Favorite Study Guide Author" finalist in a 2002 poll of CertCities readers, I know the value of good books You'll be impressed with Que Certification's stringent review process, which ensures the books are high-quality, relevant, and technically accurate Rest assured that at least a dozen industry experts—including the panel of certification experts at CramSession—have reviewed this material, helping us deliver an excellent solution to your exam preparation needs We've also added a preview edition of PrepLogic's powerful, full-featured test engine, which is trusted by certification students throughout the world As a 20-year-plus veteran of the computing industry and the original creator and editor of the Exam Cram series, I've brought my IT experience to bear on these books During my tenure at Novell from 1989 to 1994, I worked with and around its excellent education and certification department This experience helped push my writing and teaching activities heavily in the certification direction Since then, I've worked on more than 70 certification-related books, and I write about certification topics for numerous Web sites and for Certification magazine In 1996, while studying for various MCP exams, I became frustrated with the huge, unwieldy study guides that were the only preparation tools available As an experienced IT professional and former instructor, I wanted "nothing but the facts" necessary to prepare for the exams From this impetus, Exam Cram emerged in 1997 It quickly became the best-selling computer book series since "…For Dummies," and the best-selling certification book series ever By maintaining an intense focus on subject matter, tracking errata and updates quickly, and following the certification market closely, Exam Cram was able to establish the dominant position in cert prep books You will not be disappointed in your decision to purchase this book If you are, please contact me at etittel@jump.net All suggestions, ideas, input, or constructive criticism are welcome! [ Team LiB ] This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com [ Team LiB ] About the Authors Bill Brogden is LANWrights, Inc.'s Vice President of Technology and Development A fulltime programmer and writer based in Leander, Texas, Bill has more than 20 years' experience in the programming field He's worked for clients as diverse as The Psychological Corporation, Litidex, and Cox Newspapers, and has written programs ranging from text indexing and retrieval software to online courseware Bill has been helping people pass the Java programmer certification exam for years with the Exam Cram series and online example tests Marcus Green has been working with PCs since 1986 and with Internet technologies since 1992 He has written extensively on Java Programmer Certification and runs a Web site on that subject at http://www.jchq.net He has written database-backed Web sites using Perl, PHP, and JSP, and he uses Linux as his default operating system [ Team LiB ] This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com [ Team LiB ] About the Technical Editors Steve Heckler is a freelance programmer and IT trainer specializing in NET, Java, ColdFusion, Flash ActionScript, and XML Based in Atlanta, Georgia, he works with clients nationwide In addition, he is the author of the Sun Certification Instructor Resource Kit (310-025, 310-027): Java Programmer and Developer Exams and Sun Certification Instructor Resource Kit (310-080): Java Web Component Developer Exam, both from Que Publishing Prior to being self-employed, he served nearly seven years as vice president and president of a leading East Coast IT training firm He holds bachelors and masters degrees from Stanford University Ger Button has extensive and diversified experience in software development projects, including customizing systems, training developers, and installing remittance-processing systems for municipalities and corporations across the country One of his more interesting projects was the two-month evaluation of a Norwegian bank's paperless Teller Software System Ger's transition to Java was prompted by ATT's need for a customized Internet bank prototype that was demonstrated at a national trade show Teaching has been a significant part of his projects, and he has encouraged mentoring relationships that transfer skills to other team members he works with His other interests range from building custom PCs to flying gliders Ger is Sun certified as both a Java Programmer and a Java instructor, and can be reached at JavaTrek.com [ Team LiB ] This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com super keyword 2nd thrown exceptions variables overriding methods overriding subclass methods exceptions [ Team LiB ] This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com [ Team LiB ] [SYMBOL] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [R] [S] [T] [U] [V] [W] [Y] package declarations package visibility packages Java program structures 2nd naming 2nd polymorphism pow methods Math class practice tests PrepLogic customer service PrepLogic Practice Tests, Preview Edition 2nd 3rd exam simulation interface design question quality Examination Score Report screen 2nd Flash Review mode installing software navigating 2nd Practice Exam mode removing software software requirements 2nd viewing time remaining display Your Score Report screen PrepLogic Web site primitive arrays casting primitive variables wrapper classes primitives boolean primitives boolean prmitives ! operators casting floating-point primitives to integer primitives 2nd 3rd narrowing conversions character primitives escape sequences conversions impossible conversions method signatures 2nd narrowing conversions widening conversions 2nd 3rd 4th float primitives floating-point values 2nd floating-point primitives 2nd casting to integer primitives 2nd 3rd integer primitives bitwise operators 2nd 3rd integer prmitives (~) operators short primitives bitwise operators printing This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com test results priority variable threads 2nd private members private methods overriding methods 2nd private visibility program conventions 2nd program structures classes 2nd import statements 2nd packages 2nd source codes comments protected members protected methods protected visibility public classes public members public methods public visibility [ Team LiB ] This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com [ Team LiB ] [SYMBOL] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [R] [S] [T] [U] [V] [W] [Y] random methods Math class recycling memory 2nd finalizer methods 2nd memory traps 2nd string objects 2nd reference type arrays casting 2nd reference variables 2nd 3rd references array references conversions 2nd class references conversions 2nd conversions 2nd instanceof operators 2nd 3rd interface references 2nd null value references object hierarchies 2nd 3rd widening conversions interface references conversions 2nd multiple interface references null value references object references conversions 2nd instanceof operators 2nd 3rd interface references 2nd null value references object hierarchies 2nd 3rd Reflection API (application programming interface) 2nd JavaBeans API object serialization reserved keywords 2nd visibility package visibility private visibility protected visibility public visibility resume method rethrowing exceptions return types overriding methods right shift (2ab) operators 2nd = assignment operators right shift (3ab) operators 2nd = assignment operators round methods Math class Runnable interface threads 2nd 3rd 4th Runnable interfaces running threads This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com Runtime class runtime method System class [ Team LiB ] This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com [ Team LiB ] [SYMBOL] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [R] [S] [T] [U] [V] [W] [Y] scope local variables 2nd final modifier scoring tests Set interface shadowing variables shift operators