Sumário Itens Encontrados: 293Chapter 1 Advanced Class Design 1Chapter 2 Design Patterns and Principles 47Chapter 3 Generics and Collections 103Chapter 4 Functional Programming 171Chapter 5 Dates,Strings,and Localization 233Chapter 6 Exceptions and Assertions 283Chapter 7 Concurrency 325Chapter 8 IO 405Chapter 9 NIO.2 453Chapter 10 JDBC 505Appendix A Answers to Review Questions 547Appendix B Study Tips 575Appendix C Upgrading from Java 6 or Earlier 595Index 649Reviewing OCA Concepts 2Access Modifiers 2Overloading and Overriding 4Abstract Classes 5Static and Final 6Imports 6Using instanceof 7Understanding Virtual Method Invocation 9Annotating Overridden Methods 11Coding equals,hashCode,and toString 13toString 13equals 15hashCode 18Working with Enums 20Using Enums in Switch Statements 21Adding Constructors,Fields,and Methods 22Creating Nested Classes 24Member Inner Classes 25Local Inner Classes 27Anonymous Inner Classes 29Static Nested Classes 31Summary 33Exam Essentials 34Review Questions 36Designing an Interface 48Purpose of an Interface 51Introducing Functional Programming 52Defining a Functional Interface 53Implementing Functional Interfaces with Lambdas 55Applying the Predicate Interface 60Implementing Polymorphism 61Distinguishing between an Object and a Reference 63Casting Object References 64Understanding Design Principles 66Encapsulating Data 66Creating JavaBeans 69Applying the Is?a Relationship 71Applying the Has?a Relationship 73Composing Objects 74Working with Design Patterns 75Applying the Singleton Pattern 76Creating Immutable Objects 82Using the Builder Pattern 86Creating Objects with the Factory Pattern 89Summary 93Exam Essentials 93Review Questions 95Reviewing OCA Collections 104Array and ArrayList 104Searching and Sorting 105Wrapper Classes and Autoboxing 106The Diamond Operator 107Working with Generics 108Generic Classes 109Generic Interfaces 112Generic Methods 114Interacting with Legacy Code 114Bounds 117Putting It All Together 122Using Lists,Sets,Maps,and Queues 124Common Collections Methods 125Using the List Interface 127Using the Set Interface 132Using the Queue Interface 134Map 138Comparing Collection Types 140Comparator vs. Comparable 143Comparable 143Comparator 146Searching and Sorting 150Additions in Java 8 152Using Method References 152Removing Conditionally 154Updating All Elements 155Looping through a Collection 155Using New Java 8 Map APIs 155Summary 159Exam Essentials 161Review Questions 162Using Variables in Lambdas 172Working with Built-In Functional Interfaces 173Implementing Supplier 174Implementing Consumer and BiConsumer 175Implementing Predicate and BiPredicate 177Implementing Function and BiFunction 178Implementing UnaryOperator and BinaryOperator 180Checking Functional Interfaces 181Returning an Optional 182Using Streams 185Creating Stream Sources 188Using Common Terminal Operations 189Using Common Intermediate Operations 196Putting Together the Pipeline 200Printing a Stream 204Working with Primitives 205Creating Primitive Streams 205Using Optional with Primitive Streams 208Summarizing Statistics 210Learning the Functional Interfaces for Primitives 210Working with Advanced Stream Pipeline Concepts 213Linking Streams to the Underlying Data 213Chaining Optionals 214Collecting Results 217Summary 223Exam Essentials 224Review Questions 226Working with Dates and Times 234Creating Dates and Times 235Manipulating Dates and Times 241Working with Periods 244Working with Durations 247Accounting for Daylight Savings Time 251Reviewing the String class 253Adding Internationalizationand Localization 255Picking a Locale 256Using a Resource Bundle 258Formatting Numbers 267Formatting Dates and Times 270Summary 273Exam Essentials 274Review Questions 276Reviewing Exceptions 284Exceptions Terminology 284Categories of Exceptions 285Exceptions on the OCP 286Try Statement 288Throw vs. Throws 289Creating Custom Exceptions 289Using Multi-catch 291Using Try-With-Resources 296Try-With-Resources Basics 298AutoCloseable 300Suppressed Exceptions 302Putting It Together 305Rethrowing Exceptions 305Working with Assertions 308The assert Statement 308Enabling Assertions 309Using Assertions 310Summary 314Exam Essentials 315Review Questions 316Introducing Threads 327Distinguishing Thread Types 328Understanding Thread Concurrency 328Introducing Runnable 330Creating a Thread 331Polling with Sleep 334Creating Threads with the ExecutorService 335Introducing the Single-Thread Executor 335Shutting Down a Thread Executor 337Submitting Tasks 338Waiting for Results 340Scheduling Tasks 345Increasing Concurrency with Pools 348Synchronizing Data Access 350Protecting Data with Atomic Classes 352Improving Access with Synchronized Blocks 354Synchronizing Methods 356Understanding the Cost of Synchronization 357Using Concurrent Collections 358Introducing Concurrent Collections 358Understanding Memory Consistency Errors 359Working with Concurrent Classes 360Obtaining Synchronized Collections 365Working with Parallel Streams 366Creating Parallel Streams 366Processing Tasks in Parallel 367Processing Parallel Reductions 372Managing Concurrent Processes 377Creating a CyclicBarrier 377Applying the Fork/Join Framework 381Identifying Threading Problems 387Understanding Liveness 387Managing Race Conditions 391Summary 392Exam Essentials 393Review Questions 394Understanding Files and Directories 406Conceptualizing the File System 406Introducing the File Class 407Introducing Streams 411Stream Fundamentals 411Stream Nomenclature 412Common Stream Operations 418Working with Streams 420The FileInputStream and FileOutputStream Classes 420The FileReader and FileWriter classes 424The ObjectInputStream and ObjectOutputStream Classes 426The PrintStream and PrintWriter Classes 432Review of Stream Classes 435Interacting with Users 437The Old Way 437The New Way 438Summary 442Exam Essentials 443Review Questions 445Introducing NIO.2 454Introducing Path 455Creating Paths 456Interacting with Paths and Files 460Providing Optional Arguments 461Using Path Objects 462Interacting with Files 471Understanding File Attributes 478Discovering Basic File Attributes 478Improving Access with Views 483Presenting the New Stream Methods 487Conceptualizing Directory Walking 487Walking a Directory 488Searching a Directory 490Comparing Legacy File and NIO.2 Methods 494Summary 495Exam Essentials 495Review Questions 497Introducing Relational Databases and SQL 507Identifying the Structure of a Relational Database 508Writing Basic SQL Statements 510Introducing the Interfaces of JDBC 511Connecting to a Database 513Building a JDBC URL 513Getting a Database Connection 515Obtaining a Statement 518Choosing a ResultSet Type 519Choosing a ResultSet Concurrency Mode 520Executing a Statement 520Getting Data from a ResultSet 524Reading a ResultSet 524Getting Data for a Column 526Scrolling ResultSet 529Closing Database Resources 533Dealing with Exceptions 535Summary 536Exam Essentials 537Review Questions 539Chapter 1: Advanced Class Design 548Chapter 2: Design Patterns and Principles 550Chapter 3: Generics and Collections 553Chapter 4: Functional Programming 556Chapter 5: Dates,Strings,and Localization 558Chapter 6: Exceptions and Assertions 560Chapter 7: Concurrency 561Chapter 8: IO 565Chapter 9: NIO.2 568Chapter 10: JDBC 571Studying for the Test 576Creating a Study Plan 576Comparing Previous Exams 578Creating and Running Sample Applications 579Taking the Test 582Understanding the Question 582Taking Advantage of the Exam Software 587Using the Provided Writing Material 587Choosing the Best Answer 590Optimizing Your Time 591Getting a Good Nightâs Rest 593Enhancing the Java Language 596Using the Diamond Operator 596Creating Literals 597Making Decisions with Switch 598Formatting and Parsing 603Using DecimalFormat Flags 603Using DateFormat 603Formatting 604Parsing 605Custom Date Formats 606Applying Locks 607Understanding the Lock Framework 607Using a ReentrantLock 610Understanding Read/Write Locks 614Using a ReentrantReadWriteLock 615Working with Directories 617Traversing Directories 618Monitoring a Directory for Changes 625Summary 633Exam Essentials 633Review Questions 635Answers to Practice Test 645