OCA/OCP Java SE 7 Programmer I & II Study Guide (Exams 1Z0-803 & 1Z0-804)

Book description

A complete update to the definitive, bestselling guide to the #1 certification for Java programmers

  • Written and revised by the co-developers of the original SCJP exam and now published in the Oracle Press brand
  • Includes two complete practice exams—250+ practice exam questions in book and via electronic content
  • Replaces SCJP Sun Certified Programmer for Java Study Guide—150,000 copies sold

Table of contents

  1. Cover
  2. Title Page
  3. Copyright Page
  4. Dedication
  5. Contents
  6. Contributors
  7. Acknowledgments
  8. Preface
  9. Introduction
  10. Part I OCA and OCP
    1. 1 Declarations and Access Control
      1. Java Refresher
      2. Identifiers and Keywords (OCA Objectives 1.2 and 2.1)
        1. Legal Identifiers
        2. Oracle’s Java Code Conventions
      3. Define Classes (OCA Objectives 1.2, 1.3, 1.4, 6.6, and 7.6)
        1. Source File Declaration Rules
        2. Using the javac and java Commands
        3. Using public static void main(String[ ] args)
        4. Import Statements and the Java API
        5. Static Import Statements
        6. Class Declarations and Modifiers
        7. Exercise 1-1: Creating an Abstract Superclass and Concrete Subclass
      4. Use Interfaces (OCA Objective 7.6)
        1. Declaring an Interface
        2. Declaring Interface Constants
      5. Declare Class Members (OCA Objectives 2.1, 2.2, 2.3, 2.4, 2.5, 4.1, 4.2, 6.2, and 6.6)
        1. Access Modifiers
        2. Nonaccess Member Modifiers
        3. Constructor Declarations
        4. Variable Declarations
      6. Declare and Use enums (OCA Objective 1.2 and OCP Objective 2.5)
        1. Declaring enums
        2. Two-Minute Drill
      7. Q&A Self Test
        1. Self Test Answers
    2. 2 Object Orientation
      1. Encapsulation (OCA Objectives 6.1 and 6.7)
      2. Inheritance and Polymorphism (OCA Objectives 7.1, 7.2, and 7.3)
        1. IS-A
        2. HAS-A
      3. Polymorphism (OCA Objectives 7.2 and 7.3)
      4. Overriding / Overloading (OCA Objectives 6.1, 6.3, 7.2, and 7.3)
        1. Overridden Methods
        2. Overloaded Methods
      5. Casting (OCA Objectives 7.3 and 7.4)
      6. Implementing an Interface (OCA Objective 7.6)
      7. Legal Return Types (OCA Objectives 2.2, 2.5, 6.1, and 6.3)
        1. Return Type Declarations
        2. Returning a Value
      8. Constructors and Instantiation (OCA Objectives 6.4, 6.5, and 7.5)
        1. Determine Whether a Default Constructor Will Be Created
        2. Overloaded Constructors
        3. Initialization Blocks
      9. Statics (OCA Objective 6.2)
        1. Static Variables and Methods
        2. Two-Minute Drill
      10. Q&A Self Test
        1. Self Test Answers
    3. 3 Assignments
      1. Stack and Heap—Quick Review
      2. Literals, Assignments, and Variables (OCA Objectives 2.1, 2.2, 2.3, and Upgrade Objective 1.2)
        1. Literal Values for All Primitive Types
        2. Assignment Operators
        3. Exercise 3-1: Casting Primitives
      3. Scope (OCA Objectives 1.1 and 2.5)
      4. Variable Initialization (OCA Objective 2.1)
        1. Using a Variable or Array Element That Is Uninitialized and Unassigned
        2. Local (Stack, Automatic) Primitives and Objects
      5. Passing Variables into Methods (OCA Objective 6.8)
        1. Passing Object Reference Variables
        2. Does Java Use Pass-By-Value Semantics?
        3. Passing Primitive Variables
      6. Garbage Collection (OCA Objective 2.4)
        1. Overview of Memory Management and Garbage Collection
        2. Overview of Java’s Garbage Collector
        3. Writing Code That Explicitly Makes Objects Eligible for Collection
        4. Exercise 3-2: Garbage Collection Experiment
        5. Two-Minute Drill
      7. Q&A Self Test
        1. Self Test Answers
    4. 4 Operators
      1. Java Operators (OCA Objectives 3.1, 3.2, and 3.3)
        1. Assignment Operators
        2. Relational Operators
        3. instanceof Comparison
        4. Arithmetic Operators
        5. Conditional Operator
        6. Logical Operators
        7. Two-Minute Drill
      2. Q&A Self Test
        1. Self Test Answers
    5. 5 Working with Strings, Arrays, and ArrayLists
      1. Using String and StringBuilder (OCA Objectives 2.7 and 2.6)
        1. The String Class
        2. Important Facts About Strings and Memory
        3. Important Methods in the String Class
        4. The StringBuilder Class
        5. Important Methods in the StringBuilder Class
      2. Using Arrays (OCA Objectives 4.1 and 4.2)
        1. Declaring an Array
        2. Constructing an Array
        3. Initializing an Array
      3. Using ArrayList (OCA Objective 4.3)
        1. When to Use ArrayLists
        2. ArrayList Methods in Action
        3. Important Methods in the ArrayList Class
        4. Encapsulation for Reference Variables
        5. Two-Minute Drill
      4. Q&A Self Test
        1. Self Test Answers
    6. 6 Flow Control and Exceptions
      1. Using if and switch Statements (OCA Objectives 3.4 and 3.5—also Upgrade Objective 1.1)
        1. if-else Branching
        2. switch Statements (OCA, OCP, and Upgrade Topic)
      2. Exercise 6-1: Creating a switch-case Statement
      3. Creating Loops Constructs (OCA Objectives 5.1, 5.2, 5.3, 5.4, and 5.5)
        1. Using while Loops
        2. Using do Loops
        3. Using for Loops
        4. Using break and continue
        5. Unlabeled Statements
        6. Labeled Statements
      4. Exercise 6-2: Creating a Labeled while Loop
      5. Handling Exceptions (OCA Objectives 8.1, 8.2, 8.3, and 8.4)
        1. Catching an Exception Using try and catch
        2. Using finally
        3. Propagating Uncaught Exceptions
      6. Exercise 6-3: Propagating and Catching an Exception
        1. Defining Exceptions
        2. Exception Hierarchy
        3. Handling an Entire Class Hierarchy of Exceptions
        4. Exception Matching
        5. Exception Declaration and the Public Interface
        6. Rethrowing the Same Exception
        7. Exercise 6-4: Creating an Exception
      7. Common Exceptions and Errors (OCA Objective 8.5)
        1. Where Exceptions Come From
        2. JVM Thrown Exceptions
        3. Programmatically Thrown Exceptions
        4. A Summary of the Exam’s Exceptions and Errors
        5. End of Part I—OCA
        6. Two-Minute Drill
      8. Q&A Self Test
        1. Self Test Answers
  11. Part II OCP
    1. 7 Assertions and Java 7 Exceptions
      1. Working with the Assertion Mechanism (OCP Objective 6.5)
        1. Assertions Overview
        2. Enabling Assertions
        3. Using Assertions Appropriately
      2. Working with Java 7 Exception Handling (OCP Objectives 6.2 and 6.3)
        1. Use the try Statement with multi-catch and finally Clauses
        2. Autocloseable Resources with a try-with-resources Statement
        3. Two-Minute Drill
      3. Q&A Self Test
        1. Self Test Answers
    2. 8 String Processing, Data Formatting, Resource Bundles
      1. String, StringBuilder, and StringBuffer (OCP Objective 5.1)
      2. Dates, Numbers, Currencies, and Locales (OCP Objectives 12.1, 12.4, 12.5, and 12.6)
        1. Working with Dates, Numbers, and Currencies
      3. Parsing, Tokenizing, and Formatting (OCP Objectives 5.1, 5.2, and 5.3)
        1. A Search Tutorial
        2. Locating Data via Pattern Matching
        3. Tokenizing
        4. Formatting with printf() and format()
      4. Resource Bundles (OCP Objectives 12.2, 12.3, and 12.5)
        1. Resource Bundles
        2. Property Resource Bundles
        3. Java Resource Bundles
        4. Default Locale
        5. Choosing the Right Resource Bundle
        6. Two-Minute Drill
      5. Q&A Self Test
        1. Self Test Answers
    3. 9 I/O and NIO
      1. File Navigation and I/O (OCP Objectives 7.1 and 7.2)
        1. Creating Files Using the File Class
        2. Using FileWriter and FileReader
        3. Combining I/O Classes
        4. Working with Files and Directories
        5. The java.io.Console Class
      2. Files, Path, and Paths (OCP Objectives 8.1 and 8.2)
        1. Creating a Path
        2. Creating Files and Directories
        3. Copying, Moving, and Deleting Files
        4. Retrieving Information about a Path
        5. Normalizing a Path
        6. Resolving a Path
        7. Relativizing a Path
      3. File and Directory Attributes (OCP Objective 8.3)
        1. Reading and Writing Attributes the Easy Way
        2. Types of Attribute Interfaces
        3. Working with BasicFileAttributes
        4. Working with DosFileAttributes
        5. Working with PosixFileAttributes
        6. Reviewing Attributes
      4. DirectoryStream (OCP Objective 8.4)
      5. FileVisitor (OCP Objective 8.4)
      6. PathMatcher (OCP Objective 8.5)
      7. WatchService (OCP Objective 8.6)
      8. Serialization (Objective 7.2)
        1. Two-Minute Drill
      9. Q&A Self Test
        1. Self Test Answers
    4. 10 Advanced OO and Design Patterns
      1. IS-A and HAS-A (OCP Objectives 3.3 and 3.4)
      2. Coupling and Cohesion
        1. Coupling
        2. Cohesion
      3. Object Composition Principles (OCP Objective 3.4)
        1. Polymorphism
        2. Benefits of Composition
      4. Singleton Design Pattern (OCP Objective 3.5)
        1. What Is a Design Pattern?
        2. Problem
        3. Solution
        4. Benefits
      5. DAO Design Pattern (OCP Objective 3.6)
        1. Problem
        2. Solution
        3. Benefits
      6. Factory Design Pattern (OCP Objective 3.7)
        1. Problem
        2. Solution
        3. Benefits
        4. Two-Minute Drill
      7. Q&A Self Test
        1. Self Test Answers
    5. 11 Generics and Collections
      1. toString(), hashCode(), and equals() (OCP Objectives 4.7 and 4.8)
        1. The toString() Method
        2. Overriding equals()
        3. Overriding hashCode()
      2. Collections Overview (OCP Objectives 4.5 and 4.6)
        1. So What Do You Do with a Collection?
        2. Key Interfaces and Classes of the Collections Framework
        3. List Interface
        4. Set Interface
        5. Map Interface
        6. Queue Interface
      3. Using Collections (OCP Objectives 4.2, 4.4, 4.5, 4.6, 4.7, and 4.8)
        1. ArrayList Basics
        2. Autoboxing with Collections
        3. The Java 7 “Diamond” Syntax
        4. Sorting Collections and Arrays
        5. Navigating (Searching) TreeSets and TreeMaps
        6. Other Navigation Methods
        7. Backed Collections
        8. Using the PriorityQueue Class and the Deque Interface
        9. Method Overview for Arrays and Collections
        10. Method Overview for List, Set, Map, and Queue
      4. Generic Types (OCP Objectives 4.1 and 4.3)
        1. The Legacy Way to Do Collections
        2. Generics and Legacy Code
        3. Mixing Generic and Nongeneric Collections
        4. Polymorphism and Generics
        5. Generic Methods
        6. Generic Declarations
        7. Two-Minute Drill
      5. Q&A Self Test
        1. Self Test Answers
    6. 12 Inner Classes
      1. Nested Classes (OCP Objective 2.4)
      2. Inner Classes
        1. Coding a “Regular” Inner Class
        2. Referencing the Inner or Outer Instance from Within the Inner Class
      3. Method-Local Inner Classes
        1. What a Method-Local Inner Object Can and Can’t Do
      4. Anonymous Inner Classes
        1. Plain-Old Anonymous Inner Classes, Flavor One
        2. Plain-Old Anonymous Inner Classes, Flavor Two
        3. Argument-Defined Anonymous Inner Classes
      5. Static Nested Classes
        1. Instantiating and Using Static Nested Classes
        2. Two-Minute Drill
      6. Q&A Self Test
        1. Self Test Answers
    7. 13 Threads
      1. Defining, Instantiating, and Starting Threads (OCP Objective 10.1)
        1. Defining a Thread
        2. Instantiating a Thread
        3. Starting a Thread
      2. Thread States and Transitions (OCP Objective 10.2)
        1. Thread States
        2. Preventing Thread Execution
        3. Sleeping
        4. Exercise 13-1: Creating a Thread and Putting It to Sleep
        5. Thread Priorities and yield( )
      3. Synchronizing Code, Thread Problems (OCP Objectives 10.3 and 10.4)
        1. Synchronization and Locks
        2. Exercise 13-2: Synchronizing a Block of Code
        3. Thread Deadlock
      4. Thread Interaction (OCP Objectives 10.3 and 10.4)
        1. Using notifyAll( ) When Many Threads May Be Waiting
        2. Two-Minute Drill
      5. Q&A Self Test
        1. Self Test Answers
        2. Exercise Answers
    8. 14 Concurrency
      1. Concurrency with the java.util.concurrent Package
      2. Apply Atomic Variables and Locks (OCP Objective 11.2)
        1. Atomic Variables
        2. Locks
      3. Use java.util.concurrent Collections (OCP Objective 11.1) and Use a Deque (OCP Objective 4.5)
        1. Copy-on-Write Collections
        2. Concurrent Collections
        3. Blocking Queues
      4. Use Executors and ThreadPools (OCP Objective 11.3)
        1. Identifying Parallel Tasks
        2. How Many Threads Can You Run?
        3. CPU-Intensive vs. I/O-Intensive Tasks
        4. Fighting for a Turn
        5. Decoupling Tasks from Threads
      5. Use the Parallel Fork/Join Framework (OCP Objective 11.4)
        1. Divide and Conquer
        2. ForkJoinPool
        3. ForkJoinTask
        4. Two-Minute Drill
      6. Q&A Self Test
        1. Self Test Answers
    9. 15 JDBC
      1. Starting Out: Introduction to Databases and JDBC
        1. Talking to a Database
        2. Bob’s Books, Our Test Database
      2. Core Interfaces of the JDBC API (OCP Objective 9.1)
      3. Connect to a Database Using DriverManager (OCP Objective 9.2)
        1. The DriverManager Class
        2. The JDBC URL
        3. JDBC Driver Implementation Versions
      4. Submit Queries and Read Results from the Database (OCP Objective 9.3)
        1. All of Bob’s Customers
        2. Statements
        3. ResultSets
        4. Updating ResultSets (Not on the Exam!)
        5. When Things Go Wrong—Exceptions and Warnings
      5. Use PreparedStatement and CallableStatement Objects (OCP Objective 9.6)
        1. PreparedStatement
        2. CallableStatement
      6. Construct and Use RowSet Objects (OCP Objective 9.5)
        1. Working with RowSets
      7. JDBC Transactions (OCP Objective 9.4)
        1. JDBC Transaction Concepts
        2. Starting a Transaction Context in JDBC
        3. Rolling Back a Transaction
        4. Using Savepoints with JDBC
        5. Two-Minute Drill
      8. Q&A Self Test
        1. Self Test Answers
  12. Appendix A Serialization
  13. Appendix B Classpaths and JARs
  14. Appendix C About the Download
  15. Index

Product information

  • Title: OCA/OCP Java SE 7 Programmer I & II Study Guide (Exams 1Z0-803 & 1Z0-804)
  • Author(s): Kathy Sierra, Bert Bates
  • Release date: October 2014
  • Publisher(s): Oracle Press
  • ISBN: 9780071771993