| |
 |
Copyright |
| |
 |
List of Figures |
| |
 |
List of Tables |
| |
 |
List of Examples |
| |
 |
Foreword |
| |
 |
Preface |
| |
|
 |
Writing the Second
Edition |
| |
|
 |
About This Book |
| |
|
 |
Using the Book |
| |
|
 |
Review Questions |
| |
|
 |
Chapter Summary |
| |
|
 |
Programming Exercises |
| |
|
 |
Book Web Sites |
| |
|
 |
Request for Feedback |
| |
|
 |
About the Authors |
| |
|
 |
Acknowledgments
(First Edition) |
| |
|
 |
Acknowledgments
(Second Edition) |
 |
| |
 |
Chapter 1. Basics of Java
Programming |
| |
|
 |
Section 1.1.
Introduction |
| |
|
 |
Section 1.2. Classes |
| |
|
 |
Section 1.3. Objects |
| |
|
 |
Section 1.4. Instance
Members |
| |
|
 |
Section 1.5. Static
Members |
| |
|
 |
Section 1.6.
Inheritance |
| |
|
 |
Section 1.7.
Aggregation |
| |
|
 |
Section 1.8. Tenets
of Java |
| |
|
 |
Review Questions |
| |
|
 |
Section 1.9. Java
Programs |
| |
|
 |
Section 1.10. Sample
Java Application |
| |
|
 |
Review Questions |
| |
|
 |
Chapter Summary |
| |
|
 |
Programming Exercises |
 |
| |
 |
Chapter 2. Language
Fundamentals |
| |
|
 |
Section 2.1. Basic
Language Elements |
| |
|
 |
Review Questions |
| |
|
 |
Section 2.2.
Primitive Data Types |
| |
|
 |
Review Questions |
| |
|
 |
Section 2.3. Variable
Declarations |
| |
|
 |
Section 2.4. Initial
Values for Variables |
| |
|
 |
Review Questions |
| |
|
 |
Section 2.5. Java
Source File Structure |
| |
|
 |
Review Questions |
| |
|
 |
Section 2.6. The
main() Method |
| |
|
 |
Review Questions |
| |
|
 |
Chapter Summary |
| |
|
 |
Programming Exercises |
 |
| |
 |
Chapter 3. Operators and
Assignments |
| |
|
 |
Section 3.1.
Precedence and Associativity Rules for Operators |
| |
|
 |
Section 3.2.
Evaluation Order of Operands |
| |
|
 |
Section 3.3.
Conversions |
| |
|
 |
Section 3.4. Simple
Assignment Operator = |
| |
|
 |
Review Questions |
| |
|
 |
Section 3.5.
Arithmetic Operators: *, /, %, +,
- |
| |
|
 |
Review Questions |
| |
|
 |
Section 3.6. The
Binary String Concatenation Operator + |
| |
|
 |
Section 3.7. Variable
Increment and Decrement Operators: ++, -- |
| |
|
 |
Review Questions |
| |
|
 |
Section 3.8. Boolean
Expressions |
| |
|
 |
Section 3.9.
Relational Operators: <, <=, >, >= |
| |
|
 |
Section 3.10.
Equality |
| |
|
 |
Section 3.11.
Boolean Logical Operators: !, ^, &, | |
| |
|
 |
Section 3.12.
Conditional Operators: &&, || |
| |
|
 |
Review Questions |
| |
|
 |
Section 3.13.
Integer Bitwise Operators: ~, &, |, ^ |
| |
|
 |
Section 3.14. Shift
Operators: <<, >>, >>> |
| |
|
 |
Section 3.15. The
Conditional Operator: ? |
| |
|
 |
Section 3.16. Other
Operators: new, [], instanceof |
| |
|
 |
Review Questions |
| |
|
 |
Section 3.17.
Parameter Passing |
| |
|
 |
Section 3.18.
Passing Primitive Data Values |
| |
|
 |
Section 3.19.
Passing Object Reference Values |
| |
|
 |
Section 3.20.
Passing Array References |
| |
|
 |
Section 3.21. Array
Elements as Actual Parameters |
| |
|
 |
Section 3.22.
final Parameters |
| |
|
 |
Section 3.23.
Program Arguments |
| |
|
 |
Review Questions |
| |
|
 |
Chapter Summary |
| |
|
 |
Programming Exercises |
 |
| |
 |
Chapter 4. Declarations and
Access Control |
| |
|
 |
Section 4.1. Arrays |
| |
|
 |
Review Questions |
| |
|
 |
Section 4.2. Defining
Classes |
| |
|
 |
Section 4.3. Defining
Methods |
| |
|
 |
Section 4.4.
Constructors |
| |
|
 |
Section 4.5. Scope
Rules |
| |
|
 |
Review Questions |
| |
|
 |
Section 4.6. Packages |
| |
|
 |
Section 4.7.
Accessibility Modifiers for Top-level Classes and Interfaces |
| |
|
 |
Section 4.8. Other
Modifiers for Classes |
| |
|
 |
Review Questions |
| |
|
 |
Section 4.9. Member
Accessibility Modifiers |
| |
|
 |
Review Questions |
| |
|
 |
Section 4.10. Other
Modifiers for Members |
| |
|
 |
Review Questions |
| |
|
 |
Chapter Summary |
| |
|
 |
Programming Exercises |
 |
| |
 |
Chapter 5. Control Flow,
Exception Handling, and Assertions |
| |
|
 |
Section 5.1. Overview
of Control Flow Statements |
| |
|
 |
Section 5.2.
Selection Statements |
| |
|
 |
Review Questions |
| |
|
 |
Section 5.3.
Iteration Statements |
| |
|
 |
Section 5.4. Transfer
Statements |
| |
|
 |
Review Questions |
| |
|
 |
Section 5.5.
Stack-based Execution and Exception Propagation |
| |
|
 |
Section 5.6.
Exception Types |
| |
|
 |
Section 5.7.
Exception Handling: try, catch, and finally |
| |
|
 |
Section 5.8.
throw Statement |
| |
|
 |
Section 5.9.
throws Clause |
| |
|
 |
Review Questions |
| |
|
 |
Section 5.10.
Assertions |
| |
|
 |
Review Questions |
| |
|
 |
Chapter Summary |
| |
|
 |
Programming Exercises |
 |
| |
 |
Chapter 6. Object-oriented
Programming |
| |
|
 |
Section 6.1. Single
Implementation Inheritance |
| |
|
 |
Review Questions |
| |
|
 |
Section 6.2.
Overriding and Hiding Members |
| |
|
 |
Review Questions |
| |
|
 |
Section 6.3. Chaining
Constructors Using this() and super() |
| |
|
 |
Review Questions |
| |
|
 |
Section 6.4.
Interfaces |
| |
|
 |
Review Questions |
| |
|
 |
Section 6.5.
Completing the Type Hierarchy |
| |
|
 |
Section 6.6.
Assigning, Passing, and Casting Reference Values |
| |
|
 |
Review Questions |
| |
|
 |
Section 6.7.
Polymorphism and Dynamic Method Lookup |
| |
|
 |
Review Questions |
| |
|
 |
Section 6.8.
Inheritance vs. Aggregation |
| |
|
 |
Review Questions |
| |
|
 |
Chapter Summary |
| |
|
 |
Programming Exercises |
 |
| |
 |
Chapter 7. Nested Classes And
Interfaces |
| |
|
 |
Section 7.1. Overview
of Nested Classes and Interfaces |
| |
|
 |
Section 7.2. Static
Member Classes and Interfaces |
| |
|
 |
Section 7.3.
Non-static Member Classes |
| |
|
 |
Review Questions |
| |
|
 |
Section 7.4. Local
Classes |
| |
|
 |
Section 7.5.
Anonymous Classes |
| |
|
 |
Review Questions |
| |
|
 |
Chapter Summary |
| |
|
 |
Programming Exercise |
 |
| |
 |
Chapter 8. Object Lifetime |
| |
|
 |
Section 8.1. Garbage
Collection |
| |
|
 |
Review Questions |
| |
|
 |
Section 8.2.
Initializers |
| |
|
 |
Review Questions |
| |
|
 |
Chapter Summary |
 |
| |
 |
Chapter 9. Threads |
| |
|
 |
Section 9.1.
Multitasking |
| |
|
 |
Section 9.2. Overview
of Threads |
| |
|
 |
Section 9.3. Thread
Creation |
| |
|
 |
Review Questions |
| |
|
 |
Section 9.4.
Synchronization |
| |
|
 |
Review Questions |
| |
|
 |
Section 9.5. Thread
Transitions |
| |
|
 |
Review Questions |
| |
|
 |
Chapter Summary |
| |
|
 |
Programming Exercises |
 |
| |
 |
Chapter 10. Fundamental
Classes |
| |
|
 |
Section 10.1.
Overview of the java.lang Package |
| |
|
 |
Section 10.2. The
Object Class |
| |
|
 |
Review Questions |
| |
|
 |
Section 10.3. The
Wrapper Classes |
| |
|
 |
Review Questions |
| |
|
 |
Section 10.4. The
Math Class |
| |
|
 |
Review Questions |
| |
|
 |
Section 10.5. The
String Class |
| |
|
 |
Review Questions |
| |
|
 |
Section 10.6. The
StringBuffer Class |
| |
|
 |
Review Questions |
| |
|
 |
Chapter Summary |
| |
|
 |
Programming Exercises |
 |
| |
 |
Chapter 11. Collections and
Maps |
| |
|
 |
Section 11.1. The
Collections Framework |
| |
|
 |
Section 11.2.
Collections |
| |
|
 |
Review Questions |
| |
|
 |
Section 11.3. Sets |
| |
|
 |
Section 11.4. Lists |
| |
|
 |
Review Questions |
| |
|
 |
Section 11.5. Maps |
| |
|
 |
Section 11.6. Sorted
Sets and Sorted Maps |
| |
|
 |
Review Questions |
| |
|
 |
Section 11.7.
Implementing the equals(), hashCode(), and
compareTo() Methods |
| |
|
 |
Section 11.8.
Working with Collections |
| |
|
 |
Review Questions |
| |
|
 |
Chapter Summary |
| |
|
 |
Programming Exercises |
 |
| |
 |
Appendix A. Taking the SCPJ2
1.4 Exam |
| |
|
 |
Section A.1.
Preparing for the Programmer Exam |
| |
|
 |
Section A.2.
Registering for the Exam |
| |
|
 |
Section A.3. How the
Examination Is Conducted |
| |
|
 |
Section A.4. The
Questions |
| |
|
 |
Section A.5. Moving
on to the Developer Exam |
 |
| |
 |
Appendix B. Objectives for
the SCPJ2 1.4 Exam |
| |
|
 |
Section 1:
Declarations and Access Control (Chapter 4) |
| |
|
 |
Section 2: Flow
Control, Assertions, and Exception Handling (Chapter 5) |
| |
|
 |
Section 3: Garbage
Collection (Chapter 8) |
| |
|
 |
Section 4: Language
Fundamentals (Chapter 2) |
| |
|
 |
Section 5: Operators
and Assignments (Chapter 3) |
| |
|
 |
Section 6:
Overloading, Overriding, Runtime Type and Object Orientation (Chapter 6,
Chapter 11) |
| |
|
 |
Section 7: Threads
(Chapter 9) |
| |
|
 |
Section 8:
Fundamental Classes in the java.lang Package (Chapter 10) |
| |
|
 |
Section 9: The
Collections Framework (Chapter 11) |
 |
| |
 |
Appendix C. Objectives for
the Java 2 Platform Upgrade Exam |
| |
|
 |
Section 1:
Declarations and Access Control |
| |
|
 |
Section 2: Flow
Control, Assertions, and Exception Handling |
| |
|
 |
Section 3: Garbage
Collection |
| |
|
 |
Section 4: Language
Fundamentals |
| |
|
 |
Section 5: Operators
and Assignments |
| |
|
 |
Section 6:
Overloading, Overriding, Runtime Type and Object Orientation |
| |
|
 |
Section 7: Threads |
| |
|
 |
Section 8: The
Collections Framework |
 |
| |
 |
Appendix D. Annotated
Answers to Review Questions |
| |
|
 |
Section 1. Basics of
Java Programming |
| |
|
 |
Section 2. Language
Fundamentals |
| |
|
 |
Section 3. Operators
and Assignments |
| |
|
 |
Section 4.
Declarations and Access Control |
| |
|
 |
Section 5. Control
Flow, Exception Handling, and Assertions |
| |
|
 |
Section 6.
Object-oriented Programming |
| |
|
 |
Section 7. Nested
Classes and Interfaces |
| |
|
 |
Section 8. Object
Lifetime |
| |
|
 |
Section 9. Threads |
| |
|
 |
Section 10.
Fundamental Classes |
| |
|
 |
Section 11.
Collections and Maps |
 |
| |
 |
Appendix E. Solutions to
Programming Exercises |
| |
|
 |
Section 1. Basics of
Java Programming |
| |
|
 |
Section 2. Language
Fundamentals |
| |
|
 |
Section 3. Operators
and Assignments |
| |
|
 |
Section 4.
Declarations and Access Control |
| |
|
 |
Section 5. Control
Flow, Exception Handling, and Assertions |
| |
|
 |
Section 6.
Object-oriented Programming |
| |
|
 |
Section 7. Nested
Classes and Interfaces |
| |
|
 |
Section 8. Basics of
Java Programming |
| |
|
 |
Section 9. Threads |
| |
|
 |
Section 10.
Fundamental Classes |
| |
|
 |
Section 11.
Collections and Maps |
 |
| |
 |
Appendix F. Mock Exam |
| |
|
 |
Answers to Questions |
 |
| |
 |
Appendix G. Number Systems
and Number Representation |
| |
|
 |
Section G.1. Number
Systems |
| |
|
 |
Section G.2.
Relationship between Binary, Octal, and Hexadecimal Numbers |
| |
|
 |
Section G.3.
Converting Decimals |
| |
|
 |
Section G.4.
Representing Integers |
 |
| |
 |
Appendix H. About the CD |
| |
|
 |
Section H.1.
Whizlabs Exam Simulators |
| |
|
 |
Section H.2. Items
from the Book |
| |
 |
Single-User License Agreement |
| |
|
 |
Important Terms of
Agreement |
| |
|
 |
Remedies Provided
Under the License |
| |
|
|
Liabi |