CONTENTS

Contributors

Acknowledgments

Preface

Introduction

1 Declarations and Access Control

Java Refresher

Identifiers & JavaBeans (Objectives 1.3 and 1.4)

Legal Identifiers

Sun's Java Code Conventions

JavaBeans Standards

Declare Classes (Exam Objective 1.1)

Source File Declaration Rules

Class Declarations and Modifiers

Exercise 1-1: Creating an Abstract Superclass and Concrete Subclass

Declare Interfaces (Exam Objectives 1.1 and 1.2)

Declaring an Interface

Declaring Interface Constants

Declare Class Members (Objectives 1.3 and 1.4)

Access Modifiers

Nonaccess Member Modifiers

Constructor Declarations

Variable Declarations

Declaring Enums

Image Two-Minute Drill

Q&A Self Test

Self Test Answers

2 object orientation

Encapsulation (Exam Objective 5.1)

Inheritance, Is-A, Has-A (Exam Objective 5.5)

IS-A

HAS-A

Polymorphism (Exam Objective 5.2)

Overriding / Overloading (Exam Objectives 1.5 and 5.4)

Overridden Methods

Overloaded Methods

Reference Variable Casting (Objective 5.2)

Implementing an Interface (Exam Objective 1.2)

Legal Return Types (Exam Objective 1.5)

Return Type Declarations

Returning a Value

Constructors and Instantiation (Exam Objectives 1.6, 5.3, and 5.4)

Determine Whether a Default Constructor Will Be Created

Overloaded Constructors

Statics (Exam Objective 1.3)

Static Variables and Methods

Coupling and Cohesion (Exam Objective 5.1)

Image Two-Minute Drill

Q&A Self Test

Self Test Answers

3 Assignments

Stack and Heap—Quick Review

Literals, Assignments, and Variables (Exam Objectives 1.3 and 7.6)

Literal Values for All Primitive Types

Assignment Operators

Exercise 3-1: Casting Primitives

Using a Variable or Array Element That Is Uninitialized and Unassigned

Local (Stack, Automatic) Primitives and Objects

Passing Variables into Methods (Objective 7.3)

Passing Object Reference Variables

Does Java Use Pass-By-Value Semantics?

Passing Primitive Variables

Array Declaration, Construction, and Initialization (Exam Objective 1.3)

Declaring an Array

Constructing an Array

Initializing an Array

Initialization Blocks

Using Wrapper Classes and Boxing (Exam Objective 3.1)

An Overview of the Wrapper Classes

Creating Wrapper Objects

Using Wrapper Conversion Utilities

Autoboxing

Overloading (Exam Objectives 1.5 and 5.4)

Garbage Collection (Exam Objective 7.4)

Overview of Memory Management and Garbage Collection

Overview of Java's Garbage Collector

Writing Code That Explicitly Makes Objects Eligible for Collection

Exercise 3-2: Garbage Collection Experiment

Image Two-Minute Drill

Q&A Self Test

Self Test Answers

4 operators

Java Operators (Exam Objective 7.6)

Assignment Operators

Relational Operators

instanceof Comparison

Arithmetic Operators

Conditional Operator

Logical Operators

Image Two-Minute Drill

Q&A Self Test

Self Test Answers

5 Flow Control, exceptions, and Assertions

if and switch Statements (Exam Objective 2.1)

if-else Branching

switch Statements

Exercise 5-1: Creating a switch-case Statement

Loops and Iterators (Exam Objective 2.2)

Using while Loops

Using do Loops

Using for Loops

Using break and continue

Unlabeled Statements

Labeled Statements

Exercise 5-2: Creating a Labeled while Loop

Handling Exceptions (Exam Objectives 2.4 and 2.5)

Catching an Exception Using try and catch

Using finally

Propagating Uncaught Exceptions

Exercise 5-3: Propagating and Catching an Exception

Defining Exceptions

Exception Hierarchy

Handling an Entire Class Hierarchy of Exceptions

Exception Matching

Exception Declaration and the Public Interface

Rethrowing the Same Exception

Exercise 5-4: Creating an Exception

Common Exceptions and Errors (Exam Objective 2.6)

Working with the Assertion Mechanism (Exam Objective 2.3)

Assertions Overview

Enabling Assertions

Using Assertions Appropriately

Image Two-Minute Drill

Q&A Self Test

Self Test Answers

6 Strings, I/O, Formatting, and Parsing

String, StringBuilder, and StringBuffer (Exam Objective 3.1)

The String Class

Important Facts About Strings and Memory

Important Methods in the String Class

The StringBuffer and StringBuilder Classes

Important Methods in the StringBuffer and StringBuilder Classes

File Navigation and I/O (Exam Objective 3.2)

The java.io.Console Class

Serialization (Exam Objective 3.3)

Dates, Numbers, and Currency (Exam Objective 3.4)

Working with Dates, Numbers, and Currencies

Parsing, Tokenizing, and Formatting (Exam Objective 3.5)

A Search Tutorial

Locating Data via Pattern Matching

Tokenizing

Formatting with printf() and format()

Image Two-Minute Drill

Q&A Self Test

Self Test Answers

7 Generics and Collections

Overriding hashCode() and equals() (Objective 6.2)

Overriding equals()

Overriding hashCode()

Collections (Exam Objective 6.1)

So What Do You Do with a Collection?

List Interface

Set Interface

Map Interface

Queue Interface

Using the Collections Framework (Objectives 6.3 and 6.5)

ArrayList Basics

Autoboxing with Collections

Sorting Collections and Arrays

Navigating (Searching) TreeSets and TreeMaps

Other Navigation Methods

Backed Collections

Generic Types (Objectives 6.3 and 6.4)

Generics and Legacy Code

Mixing Generic and Non-generic Collections

Polymorphism and Generics

Generic Methods

Generic Declarations

Image Two-Minute Drill

Q&A Self Test

Self Test Answers

8 Inner Classes

Inner Classes

Coding a "Regular" Inner Class

Referencing the Inner or Outer Instance from Within the Inner Class

Method-Local Inner Classes

What a Method-Local Inner Object Can and Can't Do

Anonymous Inner Classes

Plain-Old Anonymous Inner Classes, Flavor One

Plain-Old Anonymous Inner Classes, Flavor Two

Argument-Defined Anonymous Inner Classes

Static Nested Classes

Instantiating and Using Static Nested Classes

Image Two-Minute Drill

Q&A Self Test

Self Test Answers

9 Threads

Defining, Instantiating, and Starting Threads (Objective 4.1)

Defining a Thread

Instantiating a Thread

Starting a Thread

Thread States and Transitions (Objective 4.2)

Thread States

Preventing Thread Execution

Sleeping

Exercise 9-1: Creating a Thread and Putting It to Sleep

Thread Priorities and yield( )

Synchronizing Code (Objective 4.3)

Synchronization and Locks

Exercise 9-2: Synchronizing a Block of Code

Thread Deadlock

Thread Interaction (Objective 4.4)

Using notifyAll( ) When Many Threads May Be Waiting

Image Two-Minute Drill

Q&A Self Test

Self Test Answers

Exercise Answers

10 Development

Using the javac and java Commands (Exam Objectives 7.1, 7.2, and 7.5)

Compiling with javac

Launching Applications with java

Searching for Other Classes

JAR Files (Objective 7.5)

JAR Files and Searching

Using Static Imports (Exam Objective 7.1)

Static Imports

Image Two-Minute Drill

Q&A Self Test

Self Test Answers

A About the Download

Steps to Download MasterExam

System Requirements

MasterExam

Additional Chapters

Help

Removing Installation

Technical Support

LearnKey Technical Support

Index

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.12.161.165