7.11 Reference Casting and the instanceof Operator
The Cast Operator
The instanceof Operator
Review Questions
7.12 Polymorphism and Dynamic Method Lookup
7.13 Inheritance Versus Aggregation
7.14 Basic Concepts in Object-Oriented Design
Encapsulation
Cohesion
Coupling
Review Questions
Chapter Summary
Programming Exercises
8 Nested Type Declarations
8.1 Overview of Nested Type Declarations
8.2 Static Member Types
Declaring and Using Static Member Types
Accessing Members in Enclosing Context
8.3 Non-Static Member Classes
Instantiating Non-Static Member Classes
Accessing Members in Enclosing Context
Review Questions
8.4 Local Classes
Accessing Declarations in Enclosing Context
Instantiating Local Classes
8.5 Anonymous Classes
Extending an Existing Class
Implementing an Interface
Instantiating Anonymous Classes
Accessing Declarations in Enclosing Context
Review Questions
Chapter Summary
Programming Exercise
9 Object Lifetime
9.1 Garbage Collection
9.2 Reachable Objects
9.3 Facilitating Garbage Collection
9.4 Object Finalization
9.5 Finalizer Chaining
9.6 Invoking Garbage Collection Programmatically
Review Questions
9.7 Initializers
9.8 Field Initializer Expressions
9.9 Static Initializer Blocks
9.10 Instance Initializer Blocks
9.11 Constructing Initial Object State
Review Questions
Chapter Summary
10 Fundamental Classes
10.1 Overview of the java.lang Package
10.2 The Object Class
Review Questions
10.3 The Wrapper Classes
Common Wrapper Class Constructors
Common Wrapper Class Utility Methods
Numeric Wrapper Classes
The Character Class
The Boolean Class
Review Questions
10.4 The String Class
Immutability
Creating and Initializing Strings
The CharSequence Interface
Reading Characters from a String
Comparing Strings
Character Case in a String
Concatenation of Strings
Searching for Characters and Substrings
Extracting Substrings
Converting Primitive Values and Objects to Strings
Formatting Values
Pattern Matching
Review Questions
10.5 The StringBuilder and the StringBuffer Classes
Thread-Safety
Mutability
Constructing String Builders
Reading and Changing Characters in String Builders
Constructing Strings from String Builders
Appending, Inserting, and Deleting Characters in String Builders
Controlling String Builder Capacity
Review Questions
Chapter Summary
Programming Exercises
11 Files and Streams
11.1 Input and Output
11.2 The File Class
Querying the File System
File or Directory Existence
File and Directory Permissions
Listing Directory Entries
Creating New Files and Directories
Renaming Files and Directories
Deleting Files and Directories
11.3 Byte Streams: Input Streams and Output Streams
File Streams
Filter Streams
Reading and Writing Binary Values
Review Questions
11.4 Character Streams: Readers and Writers
Print Writers
Writing Text Files
Reading Text Files
Using Buffered Writers
Using Buffered Readers
The Standard Input, Output, and Error Streams
Comparison of Byte Streams and Character Streams
11.5 The Console class
Review Questions
11.6 Object Serialization
The ObjectOutputStream Class
The ObjectInputStream Class
Customizing Object Serialization
Serialization and Inheritance
Review Questions
Chapter Summary
Programming Exercise
12 Localization, Pattern Matching, and Formatting
12.1 The java.util.Locale Class
12.2 The java.util.Date Class
12.3 The java.util.Calendar Class
Static Factory Methods to Create a Calendar
Interoperability with the Date Class
Selected get and set Methods
Manipulating a Calendar
Comparing Calendars
12.4 The java.text.DateFormat Class
Static Factory Methods to Create a Date/Time Formatter
Formatting Dates
Parsing Strings to Date/Time
Managing the Calendar and the Number Formatter
12.5 The java.text.NumberFormat Class
Static Factory Methods to Create a Number Formatter
Formatting Numbers and Currency
Parsing Strings to Numbers
Specifying the Number of Digits
Review Questions
12.6 String Pattern Matching Using Regular Expressions
Regular Expression Fundamentals
Escaping Metacharacters
The java.util.regex.Pattern Class
The java.util.regex.Matcher Class
The java.util.Scanner Class
Review Questions
12.7 Formatting Values
Overview
Defining Format Specifiers
Conversion Categories and Formatting Conversions
Selected Format Exceptions
Using the format() Method
Review Questions
Chapter Summary
Programming Exercises
13 Threads
13.1 Multitasking
13.2 Overview of Threads
13.3 The Main Thread
13.4 Thread Creation
Implementing the Runnable Interface
Extending the Thread Class
Review Questions
13.5 Synchronization
Locks
Synchronized Methods
Synchronized Blocks
Review Questions
13.6 Thread Transitions
Thread States
Thread Priorities
Thread Scheduler
Running and Yielding
Sleeping and Waking Up
Waiting and Notifying
Joining
Blocking for I/O
Thread Termination
Deadlocks
Review Questions
Chapter Summary
Programming Exercises
14 Generics
14.1 Introducing Generics
14.2 Generic Types and Parameterized Types
Generic Types
Parameterized Types
Generic Interfaces
Extending Generic Types
Raw Types and Unchecked Warnings
14.3 Collections and Generics
14.4 Wildcards
The Subtype Covariance Problem with Parameterized Types
Wildcard Types
Subtype Covariance: ? extends Type
Subtype Contravariance: ? super Type
Subtype Bivariance: ?
Subtype Invariance: Type
Some Restrictions on Wildcard Types
14.5 Using References of Wildcard Parameterized Types
Generic Reference Assignment
Using Parameterized References to Call Set and Get Methods
14.6 Bounded Type Parameters
Multiple Bounds
Review Questions
14.7 Implementing a Simplified Generic Stack
14.8 Generic Methods and Constructors
Generic Method Declaration
Calling Generic Methods
14.9 Wildcard Capture
Capture Conversion
14.10 Flexibility with Wildcard Parameterized Types
Nested Wildcards
Wildcard Parameterized Types as Formal Parameters
Flexible Comparisons with Wildcards
Recursive Bounds
14.11 Type Erasure
Bridge Methods
14.12 Implications for Overloading and Overriding
Method Signature
Implications for Overloading
Implications for Overriding
14.13 Limitations and Restrictions on Generic Types
Reifiable Types
Implications for instanceof operator
Implications for Casting
Implications for Arrays
Implications for Varargs
Implications for Exception Handling
Implications for Nested Classes
Other Implications
Review Questions
Chapter Summary
Programming Exercises
15 Collections and Maps
15.1 Comparing Objects
The equals() Method
The hashCode() Method
The Comparable<E> Interface
The Comparator<E> Interface
Review Questions
15.2 The Java Collections Framework
Core Interfaces
Implementations
15.3 Collections
Basic Operations
Bulk Operations
Iterators
Array Operations
Review Questions
15.4 Sets
The HashSet<E> and LinkedHashSet<E> Classes
15.5 The SortedSet<E> and NavigableSet<E> Interfaces
The SortedSet<E> Interface
The NavigableSet<E> Interface
The TreeSet<E> Class
15.6 Lists
The ArrayList<E>, LinkedList<E>, and Vector<E> Classes
15.7 Queues
The Queue<E> Interface
The PriorityQueue<E> and LinkedList<E> Classes
The Deque<E> Interface
The ArrayDeque<E> and LinkedList<E> Class
Review Questions
15.8 Maps
Basic Operations
Bulk Operations
Collection Views
15.9 Map Implementations
The HashMap<K,V>, LinkedHashMap<K,V>, and Hashtable<K,V> Classes
15.10 The SortedMap<K,V> and NavigableMap<K,V> Interfaces
The SortedMap<K,V> Interface
The NavigableMap<K,V> Interface
The TreeMap<K,V> Class
Review Questions
15.11 Working with Collections
Ordering Elements in Lists
Searching in Collections
Changing Elements in Collections
Sorting Arrays
Searching in Arrays
Creating List Views of Arrays
Miscellaneous Utility Methods in the Arrays Class
Review Questions
Chapter Summary
Programming Exercises
A: Taking the SCJP 1.6 Exam
A.1 Preparing for the Programmer Exam
A.2 Registering for the Exam
Obtaining an Exam Voucher
Signing Up for the Test
Contact Information
After Taking the Exam
A.3 How the Examination Is Conducted
The Testing Locations
Utilizing the Allotted Time
The Exam Program
A.4 The Questions
Types of Questions Asked
Types of Answers Expected
Topics Covered by the Questions
A.5 Moving on to Other Java Technology Exams
B: Objectives for the SCJP 1.6 Exam
C: Objectives for the SCJP 1.6 Upgrade Exam
D: Annotated Answers to Review Questions
E: Solutions to Programming Exercises
F: Mock Exam
G: Number Systems and Number Representation
G.1 Number Systems
Binary, Octal, and Hexadecimal Number System
Converting Binary Numbers to Decimals
Converting Octal and Hexadecimal Numbers to Decimals
G.2 Relationship between Binary, Octal, and Hexadecimal Numbers
G.3 Converting Decimals
Converting Decimals to Binary Numbers
Converting Decimals to Octal and Hexadecimal Numbers
G.4 Representing Integers
Calculating 2’s Complement
Index
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
Y
Z
Nội dung
[...]... java.util.Calendar Class Static Factory Methods to Create a Calendar Interoperability with the Date Class Selected get and set Methods Manipulating a Calendar Comparing Calendars The java.text.DateFormat Class Static Factory Methods to Create a Date/Time Formatter Formatting Dates Parsing Strings to Date/Time Managing the Calendar and the Number Formatter The java.text.NumberFormat Class Static Factory Methods... Reference Values Passing Arrays Array Elements as Actual Parameters final Parameters Variable Arity Methods Calling a Varargs Method Varargs and Non-Varargs Method Calls The main() Method Program Arguments Review Questions Chapter Summary Programming Exercises 4 Access Control 4.1 4.2 4.3 4.4 4.5 4.6 Java Source File Structure Packages Defining Packages Using Packages Compiling Code into Packages Running... Relationship 1.7 Class Diagram Depicting Aggregation 2.1 Primitive Data Types in Java Chapter 2 19 3.1 The Event Model Chapter 3 39 3.2 Array of Arrays 3.3 Parameter Passing: Primitive Data Values 3.4 Parameter Passing: Reference Values 3.5 Parameter Passing: Arrays 4.1 Java Source File Structure Chapter 4 103 4.2 Package Hierarchy 4.3 File Hierarchy 4.4 Searching for Classes 4.5 Searching in JAR files... Variables Reference Variables Initial Values for Variables Default Values for Fields Initializing Local Variables of Primitive Data Types Initializing Local Reference Variables Lifetime of Variables Review Questions Chapter Summary Programming Exercise Declarations 3.1 3.2 3.3 3.4 Class Declarations JavaBeans Standard Naming Patterns for Properties Naming Patterns for the Event Model Method Declarations... for Class Members Keywords in Java Reserved Literals in Java Reserved Keywords not Currently in Use Examples of Literals Examples of Decimal, Octal, and Hexadecimal Literals Examples of Character Literals Escape Sequences Examples of Escape Sequence \ddd Range of Integer Values Range of Character Values Range of Floating-Point Values Boolean Values Summary of Primitive Data Types Default Values Parameter... software • The Java programming language has become a lingua franca for programmers all over the world One can draw varied conclusions from these comments One of them is that it is of great importance that programmers working with the Java programming language should be as competent as possible The Java certification program is an important effort aimed at precisely this goal Practitioners looking to. .. Constructors and Members Implicit Static Methods for Enum Types Inherited Methods from the Enum Class Extending Enum Types: Constant-Specific Class Bodies Declaring Typesafe Enums Revisited Review Questions Arrays Declaring Array Variables Constructing an Array Initializing an Array Using an Array Anonymous Arrays Multidimensional Arrays Review Questions Parameter Passing Passing Primitive Data Values Passing... of a Class Declaration Chapter 1 1 1.2 Static Members in Class Declaration 1.3 Defining a Subclass 1.4 An Application 2.1 Default Values for Fields Chapter 2 19 2.2 Flagging Uninitialized Local Variables of Primitive Data Types 2.3 Flagging Uninitialized Local Reference Variables 3.1 A JavaBean Chapter 3 39 3.2 Using the this Reference 3.3 Namespaces 3.4 Using Enums 3.5 Declaring Enum Constructors and... 3.6 Declaring Constant-Specific Class Bodies 3.7 Using Arrays 3.8 Using Anonymous Arrays 3.9 Using Multidimensional Arrays 3.10 Passing Primitive Values 3.11 Passing Reference Values 3.12 Passing Arrays 3.13 Array Elements as Primitive Data Values 3.14 Array Elements as Reference Values 3.15 Calling a Varargs Method 3.16 Passing Program Arguments 4.1 Defining Packages and Using Type Import Chapter 4... Chapter Byte Stream Inheritance Hierarchies 11.2 Stream Chaining for Reading and Writing Binary Values toa File 11.3 Partial Character Stream Inheritance Hierarchies 11.4 Setting up a PrintWriter to Write toa File 11.5 Setting up Readers to read Characters 11.6 Buffered Writers 11.7 Buffered Readers 11.8 Keyboard and Display as Console 11.9 Object Stream Chaining 13.1 Spawning Threads Using a Runnable . Congress Cataloging-in-Publication Data
Mughal, Khalid Azim.
A programmer's guide to Java SCJP certification : a comprehensive primer / Khalid A.
Mughal,. Parameter Passing 81
Passing Primitive Data Values 82
Passing Reference Values 84
Passing Arrays 86
Array Elements as Actual Parameters 87
final
Parameters