<p><strong>Volume I (print):</strong></p> <p>Note to Reader viii<br>Figures xxiii<br>Tables xxvii<br>Examples xxxi<br>Foreword xxxix<br>Preface xli</p> <p></p> <p><strong>Chapter 1: Basics of Java Programming 1</strong><br>1.1 The Java Ecosystem 2<br>1.2 Classes 5<br>1.3 Objects 8<br>1.4 Instance Members 9<br>1.5 Static Members 10<br>1.6 Inheritance 13<br>1.7 Aggregation 16<br>Review Questions 17<br>1.8 Sample Java Program 19<br>1.9 Program Output 24<br>Review Questions 26</p> <p><strong>Chapter 2: Basic Elements, Primitive Data Types, and Operators 29</strong><br>2.1 Basic Language Elements 30<br>2.2 Primitive Data Types 41<br>2.3 Conversions 43<br>2.4 Type Conversion Contexts 46<br>2.5 Precedence and Associativity Rules for Operators 50<br>2.6 Evaluation Order of Operands 52<br>2.7 The Simple Assignment Operator = 54<br>2.8 Arithmetic Operators: *, /, %, +, - 58<br>2.9 The Binary String Concatenation Operator + 67<br>2.10 Variable Increment and Decrement Operators: ++, -- 69<br>Review Questions 71<br>2.11 Boolean Expressions 74<br>2.12 Relational Operators: <, <=, >, >= 74<br>2.13 Equality 75<br>2.14 Boolean Logical Operators: !, ^, &, | 78<br>2.15 Conditional Operators: &&, || 80<br>2.16 Integer Bitwise Operators: ~, &, |, ^ 82<br>2.17 Shift Operators: <<, >>, >>> 86<br>2.18 The Conditional Operator ?: 90<br>2.19 Other Operators: new, [], instanceof, -> 92<br>Review Questions 93</p> <p><strong>Chapter 3: Declarations 97</strong><br>3.1 Class Declarations 99<br>3.2 Method Declarations 100<br>3.3 Statements 101<br>3.4 Variable Declarations 102<br>3.5 Instance Methods and the Object Reference this 106<br>3.6 Method Overloading 108<br>3.7 Constructors 109<br>3.8 Static Member Declarations 112<br>Review Questions 115<br>3.9 Arrays 117<br>3.10 Parameter Passing 127<br>3.11 Variable Arity Methods 136<br>3.12 The main() Method 141<br>3.13 Local Variable Type Inference 142<br>Review Questions 147</p> <p><strong>Chapter 4: Control Flow 151</strong><br>4.1 Selection Statements 152<br>4.2 The switch Statement 155<br>4.3 The switch Expression 164<br>Review Questions 170<br>4.4 Iteration Statements 172<br>4.5 The while Statement 172<br>4.6 The do-while Statement 173<br>4.7 The for(;;) Statement 174<br>4.8 The for(:) Statement 176<br>4.9 Transfer Statements 179<br>4.10 Labeled Statements 179<br>4.11 The break Statement 180<br>4.12 The continue Statement 182<br>4.13 The return Statement 184<br>Review Questions 185</p> <p><strong>Chapter 5: Object-Oriented Programming 189</strong><br>5.1 Implementing Inheritance 191<br>5.2 The Object Reference super 206<br>5.3 Chaining Constructors Using this() and super() 209<br>Review Questions 215<br>5.4 Abstract Classes and Methods 218<br>5.5 Final Declarations 225<br>Review Questions 234<br>5.6 Interfaces 237<br>Review Questions 257<br>5.7 Arrays and Subtyping 259<br>5.8 Reference Values and Conversions 261<br>5.9 Reference Value Assignment Conversions 261<br>5.10 Method Invocation Conversions Involving References 265<br>5.11 Reference Casting and the instanceof Operator 269<br>5.12 Polymorphism 278<br>Review Questions 283<br>5.13 Enum Types 287<br>5.14 Record Classes 299<br>5.15 Sealed Classes and Interfaces 311<br>Review Questions 318</p> <p><strong>Chapter 6: Access Control 323</strong><br>6.1 Design Principle: Encapsulation 324<br>6.2 Java Source File Structure 325<br>6.3 Packages 326<br>6.4 Searching for Classes on the Class Path 337<br>Review Questions 341<br>6.5 Access Modifiers 345<br>6.6 Scope Rules 352<br>6.7 Implementing Immutability 356<br>Review Questions 360</p> <p><strong>Chapter 7: Exception Handling 363</strong><br>7.1 Stack-Based Execution and Exception Propagation 365<br>7.2 Exception Types 368<br>7.3 Exception Handling: try, catch, and finally 375<br>7.4 The throw Statement 386<br>7.5 The throws Clause 388<br>Review Questions 392<br>7.6 The Multi-catch Clause 397<br>7.7 The try-with-resources Statement 407<br>7.8 Advantages of Exception Handling 416<br>Review Questions 417</p> <p><strong>Chapter 8: Selected API Classes 423</strong><br>8.1 Overview of the java.lang Package 425<br>8.2 The Object Class 425<br>8.3 The Wrapper Classes 429<br>Review Questions 438<br>8.4 The String Class 439<br>8.5 The StringBuilder Class 464<br>Review Questions 471<br>8.6 The Math Class 478<br>8.7 The Random Class 482<br>8.8 Using Big Numbers 484<br>Review Questions 487</p> <p><strong>Chapter 9: Nested Type Declarations 489</strong><br>9.1 Overview of Nested Type Declarations 491<br>9.2 Static Member Types 495<br>9.3 Non-Static Member Classes 501<br>Review Questions 510<br>9.4 Local Classes 512<br>9.5 Static Local Types 519<br>9.6 Anonymous Classes 521<br>Review Questions 527</p> <p><strong>Chapter 10: Object Lifetime 531</strong><br>10.1 Garbage Collection 533<br>10.2 Reachable Objects 533<br>10.3 Facilitating Garbage Collection 536<br>10.4 Invoking Garbage Collection Programmatically 537<br>Review Questions 538<br>10.5 Initializers 540<br>10.6 Field Initializer Expressions 540<br>10.7 Static Initializer Blocks 545<br>10.8 Instance Initializer Blocks 551<br>10.9 Constructing Initial Object State 555<br>Review Questions 558</p> <p><strong>Chapter 11: Generics 563</strong><br>11.1 Introducing Generics 565<br>11.2 Generic Types and Parameterized Types 567<br>11.3 Collections and Generics 578<br>11.4 Wildcards 579<br>11.5 Using References of Wildcard Parameterized Types 584<br>11.6 Bounded Type Parameters 591<br>11.7 Generic Methods and Constructors 593<br>11.8 Implementing a Simplified Generic Stack 598<br>Review Questions 600<br>11.9 Wildcard Capture 604<br>11.10 Flexibility with Wildcard Parameterized Types 607<br>11.11 Type Erasure 613<br>11.12 Implications for Overloading and Overriding 615<br>11.13 Limitations and Restrictions on Generic Types 623<br>Review Questions 636</p> <p><strong>Chapter 12: Collections, Part I: ArrayList<E> 643</strong><br>12.1 Lists 644<br>12.2 Declaring References and Constructing ArrayLists 646<br>12.3 Modifying an ArrayList<E> 651<br>12.4 Querying an ArrayList<E> 655<br>12.5 Iterating Over an ArrayList<E> 657<br>12.6 Converting an ArrayList<E> to an Array 658<br>12.7 Creating List Views 659<br>12.8 Arrays versus ArrayLists 662<br>Review Questions 667</p> <p><strong>Chapter 13: Functional-Style Programming 673</strong><br>13.1 Functional Interfaces 675<br>13.2 Lambda Expressions 679<br>13.3 Lambda Expressions and Anonymous Classes 688<br>Review Questions 693<br>13.4 Overview of Built-In Functional Interfaces 695<br>13.5 Suppliers 699<br>13.6 Predicates 703<br>13.7 Consumers 709<br>13.8 Functions 712<br>13.9 Two-Arity Specialization of Function<T, R>: BiFunction<T, U, R> 717<br>13.10 Extending Function<T,T>: UnaryOperator<T> 720<br>13.11 Extending BiFunction<T,T,T>: BinaryOperator<T> 721<br>13.12 Currying Functions 723<br>13.13 Method and Constructor References 724<br>13.14 Contexts for Defining Lambda Expressions 733<br>Review Questions 735</p> <p><strong>Chapter 14: Object Comparison 741</strong><br>14.1 The Objects Class 743<br>14.2 Implementing the equals() Method 744<br>14.3 Implementing the hashCode() Method 753<br>14.4 Implementing the java.lang.Comparable<E> Interface 761<br>14.5 Implementing the java.util.Comparator<E> Interface 769<br>Review Questions 774</p> <p><strong>Chapter 15: Collections: Part II 781</strong><br>15.1 The Java Collections Framework 783<br>15.2 Collections 790<br>15.3 Lists 801<br>15.4 Sets 804<br>15.5 Sorted Sets and Navigable Sets 810<br>15.6 Queues 814<br>15.7 Deques 821<br>Review Questions 826<br>15.8 Maps 830<br>15.9 Map Implementations 840<br>15.10 Sorted Maps and Navigable Maps 845<br>Review Questions 851<br>15.11 The Collections Class 856<br>15.12 The Arrays Class 864<br>Review Questions 874</p> <p>Index</p> <p><strong>Volume II (print):</strong></p> <p>Note to Reader vi</p> <p><strong>Chapter 16: Streams 879</strong><br>16.1 Introduction to Streams 881<br>16.2 Running Example: The CD Record Class 882<br>16.3 Stream Basics 884<br>16.4 Building Streams 890<br>16.5 Intermediate Stream Operations 905<br>16.6 The Optional Class 940<br>16.7 Terminal Stream Operations 946<br>16.8 Collectors 978<br>16.9 Parallel Streams 1009<br>Review Questions 1016</p> <p><strong>Chapter 17: Date and Time 1023</strong><br>17.1 Date and Time API Overview 1024<br>17.2 Working with Dates and Times 1027<br>17.3 Using Temporal Units and Temporal Fields 1044<br>17.4 Working with Instants 1049<br>17.5 Working with Periods 1057<br>17.6 Working with Durations 1064<br>17.7 Working with Time Zones and Daylight Savings 1072<br>17.8 Converting Date and Time Values to Legacy Date 1088<br>Review Questions 1089</p> <p><strong>Chapter 18: Localization 1095</strong><br>18.1 Using Locales 1096<br>18.2 Properties Files 1100<br>18.3 Bundling Resources 1102<br>Review Questions 1112<br>18.4 Core API for Formatting and Parsing of Values 1115<br>18.5 Formatting and Parsing Number, Currency, and Percentage Values 1116<br>18.6 Formatting and Parsing Date and Time 1127<br>18.7 Formatting and Parsing Messages 1139<br>Review Questions 1153</p> <p><strong>Chapter 19: Java Module System 1161</strong><br>19.1 Making the Case for Modules 1163<br>19.2 The Modular JDK 1164<br>19.3 Module Basics 1168<br>19.4 Overview of Module Directives 1177<br>19.5 Creating a Modular Application 1179<br>19.6 Compiling and Running a Modular Application 1186<br>19.7 Creating JAR Files 1189<br>19.8 Open Modules and the opens Directive 1191<br>19.9 Services 1196<br>19.10 Creating Runtime Images 1204<br>19.11 Categories of Modules 1205<br>19.12 Migrating to Modules 1209<br>19.13 Exploring Modules 1211<br>19.14 Summary of Selected Operations with the JDK Tools 1218<br>Review Questions 1223</p> <p><strong>Chapter 20: Java I/O: Part I 1231</strong><br>20.1 Input and Output 1233<br>20.2 Byte Streams: Input Streams and Output Streams 1234<br>20.3 Character Streams: Readers and Writers 1241<br>20.4 The Console Class 1256<br>Review Questions 1259<br>20.5 Object Serialization 1261<br>Review Questions 1277</p> <p><strong>Chapter 21: Java I/O: Part II 1285</strong><br>21.1 Characteristics of a Hierarchical File System 1287<br>21.2 Creating Path Objects 1289<br>21.3 Working with Path Objects 1294<br>21.4 Operations on Directory Entries 1304<br>21.5 Reading and Writing Files Using Paths 1314<br>21.6 Managing File Attributes 1321<br>21.7 Creating Directory Entries 1339<br>21.8 Stream Operations on Directory Entries 1345<br>Review Questions 1355</p> <p><strong>Chapter 22: Concurrency: Part I 1365</strong><br>22.1 Threads and Concurrency 1367<br>22.2 Runtime Organization for Thread Execution 1369<br>22.3 Creating Threads 1370<br>Review Questions 1378<br>22.4 Thread Lifecycle 1380<br>22.5 Thread Issues 1408<br>Review Questions 1415</p> <p><strong>Chapter 23: Concurrency: Part II 1419</strong><br>23.1 Utility Classes TimeUnit and ThreadLocalRandom 1421<br>23.2 The Executor Framework 1423<br>23.3 The Fork/Join Framework 1447<br>23.4 Writing Thread-Safe Code 1451<br>23.5 Special-Purpose Synchronizers 1470<br>23.6 Synchronized Collections and Maps 1477<br>23.7 Concurrent Collections and Maps 1482<br>Review Questions 1504</p> <p><strong>Chapter 24: Database Connectivity 1511</strong><br>24.1 Introduction to Relational Databases 1512<br>24.2 Introduction to JDBC 1517<br>24.3 Establishing a Database Connection 1519<br>24.4 Creating and Executing SQL Statements 1522<br>24.5 Processing Query Results 1533<br>24.6 Customizing Result Sets 1539<br>24.7 Discovering Database and ResultSet Metadata 1543<br>24.8 Implementing Transaction Control 1545<br>Review Questions 1548</p> <p><strong>Chapter 25: Annotations 1555</strong><br>25.1 Basics of Annotations 1557<br>25.2 Declaring Annotation Types 1558<br>25.3 Applying Annotations 1563<br>25.4 Meta-Annotations 1567<br>25.5 Selected Standard Annotations 1577<br>25.6 Processing Annotations 1587<br>Review Questions 1593</p> <p><strong>Chapter 26: Secure Coding 1599</strong><br>26.1 Application Security Overview 1600<br>26.2 Security Threat Categories 1602<br>26.3 Java Security Policies 1608<br>26.4 Additional Security Guidelines 1610<br>Review Questions 1611</p> <p><strong>Appendix A: Taking the Java SE 17 and Java SE 11 Developer Exams 1615</strong><br>A.1 Preparing for the Exam 1615<br>A.2 Registering for the Online Proctored Exam 1616<br>A.3 How the Online Proctored Exam Is Conducted 1618<br>A.4 The Questions 1619</p> <p><strong>Appendix B: Exam Topics: Java SE 17 Developer 1623</strong></p> <p><strong>Appendix C: Exam Topics: Java SE 11 Developer 1629</strong></p> <p><strong>Appendix D: Annotated Answers to Review Questions 1635</strong></p> <p><strong>Appendix E: Mock Exam: Java SE 17 Developer 1709</strong></p> <p><strong>Appendix F: Annotated Answers to Mock Exam 1737</strong></p> <p><strong>Appendix G: Java Logging API Overview 1747</strong><br>G.1 Purpose of the Logging API 1747<br>G.2 Configuring Logging 1748<br>G.3 Writing Log Messages 1749<br>G.4 Applying Guarded Logging 1751<br>G.5 Summary 1751</p> <p>Index 1753</p>