A Programmer's Guide to Java Certification: A Comprehesive Primer, 2/e (Paperback)
Khalid A Mughal, Rolf W Rasmussen
To pass the Sun Certified Programmer for Java 2 Platform 1.4 exam (SCPJ2 1.4) you need this book. It is written for any experienced programmer (with or without previous knowledge of Java) interested in mastering the Java programming language and passing the SCPJ2 1.4 exam.
A Programmer's Guide to Java™ Certification, Second Edition, contains detailed coverage of all exam topics and objectives, helpful code examples, exercises, review questions, and several full practice exams. In addition, as a comprehensive primer to the Java programming language, this book is an invaluable reference tool for the reader.
This new edition has been thoroughly updated to focus on the latest version of the exam (CX-310-035). In particular, it contains more in-depth explanations of the syntax and usage of core language features that are now emphasized on the exam. The accompanying CD contains a version of the SCPJ2 1.4 Exam Simulator developed by Whizlabs Software, which includes several mock exams and simulates the exam-taking experience. The CD also contains the complete source code for all the examples, and solutions to the programming exercises.
What you will find in this book:
Table of Contents
List of Tables.
List of Examples.
List of Figures.
About This Book.
Using the Book.
Book Web Sites.
Request for Feedback.
About the Authors.
Acknowledgments (First Edition).
Acknowledgments (Second Edition).
1. Basics of Java Programming.
Tenets of Java.
Sample Java Application.
Compiling and Running an Application.
2. Language Fundamentals.
Primitive Data Types.
Object Reference Variables.
Lifetime of Variables.
Initial Values for Variables.
Initializing Local Variables of Primitive Data Types.
Initializing Local Reference Variables.
Java Source File Structure.
The main() Method.
3. Operators and Assignments.
Evaluation order of operands.
Narrowing and Widening Conversions.
Type Conversion Contexts.
Simple Assignment Operator =.
Numeric Type Conversions on Assignment.
Arithmetic Operators: *, /, %, +, -.
Evaluation Order in Arithmetic Expressions.
Range of Numeric Values.
Unary Arithmetic Operators: -, +.
Multiplicative Binary Operators: *, /, %.
Additive Binary Operators: +, -.
Numeric Promotions in Arithmetic Expressions.
Arithmetic Compound Assignment Operators: *=, /=, %=, +=, -=.
The Binary String Concatenation Operator +.
Variable Increment and Decrement Operators: ++, --.
Decrement Operator --.
Relational Operators: <, <=, >, >=.
Object Reference Equality: ==, !=.
Object Value Equality.
Boolean Logical Operators: !, ^, &, |.
Boolean Logical Compound Assignment Operators: &=, ^=, |=.
Conditional Operators: &&, ||.
Integer Bitwise Operators: ~, &, |, ^.
Shift Operators: <<, >>, >>>.
The Shift-right-with-sign-fill Operator >>.
The Shift-right-with-zero-fill Operator >>>.
Shift Compound Assignment Operators: <<=, >>=, >>>=.
The Conditional Operator ? :.
Other Operators: new, , instanceof.
Passing Primitive Data Values.
Passing Object Reference Values.
Passing Array References.
Array Elements as Actual Parameters.
4. Declarations and Access Control.
Constructing an Array.
Initializing an Array.
Using an Array.
Instance Methods and Object Reference this.
Block Scope for Local Variables.
Compiling and Running Code from Packages.
Accessibility Modifiers for Top-level Classes and Interfaces.
Other Modifiers for Classes.
Member Accessibility Modifiers.
Default Accessibility for Members.
Other Modifiers for Members.
5. Control Flow, Exception Handling and Assertions.
Stack-based Execution and Exception Propagation.
Checked and Unchecked Exceptions.
Defining New Exceptions.
Exception Handling: try, catch and finally.
Runtime Enabling and Disabling of Assertions.
6. Object-oriented Programming.
Overriding and Hiding Members.
Static Method Hiding.
Overriding vs. Overloading.
Object Reference super.
Chaining Constructors using this() and super().
super() Constructor Call.
Method Prototype Declarations.
Constants in Interfaces.
Completing the Type Hierarchy.
Assigning, Passing and Casting Reference Values.
Parameter Passing Conversions.
Reference Casting and instanceof Operator.
Converting References of Class and Interface Types.
Polymorphism and Dynamic Method Lookup.
Inheritance vs. Aggregation.
Choosing between Inheritance and Aggregation.
7. Nested Classes and Interfaces.
Static Member Classes and Interfaces.
Accessing Members in Enclosing Context.
Non-static Member Classes.
Accessing Members in Enclosing Context.
Instantiating Local Classes.
Implementing an Interface.
Instantiating Anonymous Classes.
Accessing Declarations in Enclosing Context.
8. Object Lifetime.
Facilitating Garbage Collection.
Invoking Garbage Collection.
Static Initializer Blocks.
Instance Initializer Blocks.
Constructing Initial Object State.
Overview of Threads.
Extending the Thread Class.
Running and Yielding.
Sleeping and Waking Up.
Waiting and Notifying.
Blocking for I/O.
10. Fundamental Classes.
The Object Class.
The Wrapper Classes.
Common Wrapper Class Utility Methods.
Numeric Wrapper Classes.
The Math Class.
Pseudorandom Number Generator.
The String Class.
Reading Characters from a String.
Character Case in a String.
Concatenation of Strings.
Searching for Characters and Substrings.
Converting Primitive Values and Objects to Strings.
The StringBuffer Class.
Reading and Changing Characters in String Buffers.
Constructing Strings from String Buffers.
Appending, Inserting and Deleting Characters in String Buffers.
Controlling String Buffer Capacity.
11. Collections and Maps.
HashMap, LinkedHashMap and Hashtable.
Sorted Sets and Sorted Maps.
The Comparable Interface.
The SortedSet Interface.
The SortedMap Interface.
TreeSet and TreeMap.
Implementing the equals(), hashCode() and compareTo() methods.
The hashCode() method.
The compareTo() method.
Working with Collections.
Unmodifiable Collection Decorators.
Searching in Collections.
Other Utility Methods in the Collections Class.
Utility Methods in the Arrays Class.
Appendix A. Taking the SCPJ2 1.4 Exam.
Registering for the exam.
Signing Up for the Test.
After Taking the Exam.
How the Examination Is Conducted.
Utilizing the Allotted time.
The Exam Program.
Types of answers expected.
Topics Covered by the Questions.
Moving on to the developer exam.
Appendix B. Objectives for the SCPJ2 1.4 Exam.
Appendix C. Objectives for the Java 2 Platform Upgrade Exam.
Appendix D. Annotated Answers to Review Questions.
Appendix E. Solutions to Programming Exercises.
Appendix F. Sample Exam.
Appendix G. Number Systems and Number Representation.
Converting Binary Numbers to Decimals.
Converting Octal and Hexadecimal Numbers to Decimals.
Relationship between Binary, Octal and Hex Numbers.
Converting Decimals to Octal and Hexadecimal Numbers.
Appendix H. Using the CD.
Installing the Programs.
Using the Programs.