Cover....1
Half Title....2
Title Page....4
Copyright Page....5
Contents Overview....10
Contents....12
Figures....22
Tables....26
Examples....30
Foreword....38
Preface....40
Writing This Book....40
About This Book....41
Using This Book....42
Book Website....44
Request for Feedback....44
About the Authors....45
Acknowledgments....45
1 Basics of Java Programming....48
1.1 The Java Ecosystem....49
1.2 Classes....52
1.3 Objects....55
1.4 Instance Members....56
1.5 Static Members....57
1.6 Inheritance....60
1.7 Aggregation....63
Review Questions....64
1.8 Sample Java Program....66
1.9 Program Output....71
Review Questions....73
2 Basic Elements, Primitive Data Types, and Operators....76
2.1 Basic Language Elements....77
2.2 Primitive Data Types....88
2.3 Conversions....90
2.4 Type Conversion Contexts....93
2.5 Precedence and Associativity Rules for Operators....97
2.6 Evaluation Order of Operands....99
2.7 The Simple Assignment Operator =....101
2.8 Arithmetic Operators: *, /, %, +, -....105
2.9 The Binary String Concatenation Operator +....114
2.10 Variable Increment and Decrement Operators: ++, --....116
Review Questions....118
2.11 Boolean Expressions....121
2.12 Relational Operators: <, <=, >, >=....121
2.13 Equality....122
2.14 Boolean Logical Operators: !, ^, &, |....125
2.15 Conditional Operators: &&, ||....127
2.16 Integer Bitwise Operators: ~, &, |, ^....129
2.17 Shift Operators: <<, >>, >>>....133
2.18 The Conditional Operator ?:....137
2.19 Other Operators: new, [], instanceof, ->....139
Review Questions....140
3 Declarations....144
3.1 Class Declarations....146
3.2 Method Declarations....147
3.3 Statements....148
3.4 Variable Declarations....149
3.5 Instance Methods and the Object Reference this....153
3.6 Method Overloading....155
3.7 Constructors....156
3.8 Static Member Declarations....159
Review Questions....162
3.9 Arrays....164
3.10 Parameter Passing....174
3.11 Variable Arity Methods....183
3.12 The main() Method....188
3.13 Local Variable Type Inference....189
Review Questions....194
4 Control Flow....198
4.1 Selection Statements....199
4.2 The switch Statement....202
4.3 The switch Expression....211
Review Questions....217
4.4 Iteration Statements....219
4.5 The while Statement....219
4.6 The do-while Statement....220
4.7 The for(;;) Statement....221
4.8 The for(:) Statement....223
4.9 Transfer Statements....226
4.10 Labeled Statements....226
4.11 The break Statement....227
4.12 The continue Statement....229
4.13 The return Statement....231
Review Questions....232
5 Object-Oriented Programming....236
5.1 Implementing Inheritance....238
5.2 The Object Reference super....253
5.3 Chaining Constructors Using this() and super()....256
Review Questions....262
5.4 Abstract Classes and Methods....265
5.5 Final Declarations....272
Review Questions....281
5.6 Interfaces....284
Review Questions....304
5.7 Arrays and Subtyping....306
5.8 Reference Values and Conversions....308
5.9 Reference Value Assignment Conversions....308
5.10 Method Invocation Conversions Involving References....312
5.11 Reference Casting and the instanceof Operator....316
5.12 Polymorphism....325
Review Questions....330
5.13 Enum Types....334
5.14 Record Classes....346
5.15 Sealed Classes and Interfaces....358
Review Questions....365
6 Access Control....370
6.1 Design Principle: Encapsulation....371
6.2 Java Source File Structure....372
6.3 Packages....373
6.4 Searching for Classes on the Class Path....384
Review Questions....388
6.5 Access Modifiers....392
6.6 Scope Rules....399
6.7 Implementing Immutability....403
Review Questions....407
7 Exception Handling....410
7.1 Stack-Based Execution and Exception Propagation....412
7.2 Exception Types....415
7.3 Exception Handling: try, catch, and finally....422
7.4 The throw Statement....433
7.5 The throws Clause....435
Review Questions....439
7.6 The Multi-catch Clause....444
7.7 The try-with-resources Statement....454
7.8 Advantages of Exception Handling....463
Review Questions....464
8 Selected API Classes....470
8.1 Overview of the java.lang Package....472
8.2 The Object Class....472
8.3 The Wrapper Classes....476
Review Questions....485
8.4 The String Class....486
8.5 The StringBuilder Class....511
Review Questions....518
8.6 The Math Class....525
8.7 The Random Class....529
8.8 Using Big Numbers....531
Review Questions....534
9 Nested Type Declarations....536
9.1 Overview of Nested Type Declarations....538
9.2 Static Member Types....542
9.3 Non-Static Member Classes....548
Review Questions....557
9.4 Local Classes....559
9.5 Static Local Types....566
9.6 Anonymous Classes....568
Review Questions....574
10 Object Lifetime....578
10.1 Garbage Collection....580
10.2 Reachable Objects....580
10.3 Facilitating Garbage Collection....583
10.4 Invoking Garbage Collection Programmatically....584
Review Questions....585
10.5 Initializers....587
10.6 Field Initializer Expressions....587
10.7 Static Initializer Blocks....592
10.8 Instance Initializer Blocks....598
10.9 Constructing Initial Object State....602
Review Questions....605
11 Generics....610
11.1 Introducing Generics....612
11.2 Generic Types and Parameterized Types....614
11.3 Collections and Generics....625
11.4 Wildcards....626
11.5 Using References of Wildcard Parameterized Types....631
11.6 Bounded Type Parameters....638
11.7 Generic Methods and Constructors....640
11.8 Implementing a Simplified Generic Stack....645
Review Questions....647
11.9 Wildcard Capture....651
11.10 Flexibility with Wildcard Parameterized Types....654
11.11 Type Erasure....660
11.12 Implications for Overloading and Overriding....662
11.13 Limitations and Restrictions on Generic Types....670
Review Questions....683
12 Collections, Part I: ArrayList....690
12.1 Lists....691
12.2 Declaring References and Constructing ArrayLists....693
12.3 Modifying an ArrayList....698
12.4 Querying an ArrayList....702
12.5 Iterating Over an ArrayList....704
12.6 Converting an ArrayList to an Array....705
12.7 Creating List Views....706
12.8 Arrays versus ArrayLists....709
Review Questions....714
13 Functional-Style Programming....720
13.1 Functional Interfaces....722
13.2 Lambda Expressions....726
13.3 Lambda Expressions and Anonymous Classes....735
Review Questions....740
13.4 Overview of Built-In Functional Interfaces....742
13.5 Suppliers....746
13.6 Predicates....750
13.7 Consumers....756
13.8 Functions....759
13.9 Two-Arity Specialization of Function: BiFunction....764
13.10 Extending Function: UnaryOperator....767
13.11 Extending BiFunction: BinaryOperator....768
13.12 Currying Functions....770
13.13 Method and Constructor References....771
13.14 Contexts for Defining Lambda Expressions....780
Review Questions....782
14 Object Comparison....788
14.1 The Objects Class....790
14.2 Implementing the equals() Method....791
14.3 Implementing the hashCode() Method....800
14.4 Implementing the java.lang.Comparable Interface....808
14.5 Implementing the java.util.Comparator Interface....816
Review Questions....821
15 Collections: Part II....828
15.1 The Java Collections Framework....830
15.2 Collections....837
15.3 Lists....848
15.4 Sets....851
15.5 Sorted Sets and Navigable Sets....857
15.6 Queues....861
15.7 Deques....868
Review Questions....873
15.8 Maps....877
15.9 Map Implementations....887
15.10 Sorted Maps and Navigable Maps....892
Review Questions....898
15.11 The Collections Class....903
15.12 The Arrays Class....911
Review Questions....921
16 Streams....927
16.1 Introduction to Streams....929
16.2 Running Example: The CD Record Class....930
16.3 Stream Basics....932
16.4 Building Streams....938
16.5 Intermediate Stream Operations....953
16.6 The Optional Class....988
16.7 Terminal Stream Operations....994
16.8 Collectors....1026
16.9 Parallel Streams....1057
Review Questions....1064
17 Date and Time....1071
17.1 Date and Time API Overview....1072
17.2 Working with Dates and Times....1075
17.3 Using Temporal Units and Temporal Fields....1092
17.4 Working with Instants....1097
17.5 Working with Periods....1105
17.6 Working with Durations....1112
17.7 Working with Time Zones and Daylight Savings....1120
17.8 Converting Date and Time Values to Legacy Date....1136
Review Questions....1137
18 Localization....1143
18.1 Using Locales....1144
18.2 Properties Files....1148
18.3 Bundling Resources....1150
Review Questions....1160
18.4 Core API for Formatting and Parsing of Values....1163
18.5 Formatting and Parsing Number, Currency, and Percentage Values....1164
18.6 Formatting and Parsing Date and Time....1175
18.7 Formatting and Parsing Messages....1187
Review Questions....1201
19 Java Module System....1209
19.1 Making the Case for Modules....1211
19.2 The Modular JDK....1212
19.3 Module Basics....1216
19.4 Overview of Module Directives....1225
19.5 Creating a Modular Application....1227
19.6 Compiling and Running a Modular Application....1234
19.7 Creating JAR Files....1237
19.8 Open Modules and the opens Directive....1239
19.9 Services....1244
19.10 Creating Runtime Images....1252
19.11 Categories of Modules....1253
19.12 Migrating to Modules....1257
19.13 Exploring Modules....1259
19.14 Summary of Selected Operations with the JDK Tools....1266
Review Questions....1271
20 Java I/O: Part I....1279
20.1 Input and Output....1281
20.2 Byte Streams: Input Streams and Output Streams....1282
20.3 Character Streams: Readers and Writers....1289
20.4 The Console Class....1304
Review Questions....1307
20.5 Object Serialization....1309
Review Questions....1325
21 Java I/O: Part II....1333
21.1 Characteristics of a Hierarchical File System....1335
21.2 Creating Path Objects....1337
21.3 Working with Path Objects....1342
21.4 Operations on Directory Entries....1352
21.5 Reading and Writing Files Using Paths....1362
21.6 Managing File Attributes....1369
21.7 Creating Directory Entries....1387
21.8 Stream Operations on Directory Entries....1393
Review Questions....1403
22 Concurrency: Part I....1413
22.1 Threads and Concurrency....1415
22.2 Runtime Organization for Thread Execution....1417
22.3 Creating Threads....1418
Review Questions....1426
22.4 Thread Lifecycle....1428
22.5 Thread Issues....1456
Review Questions....1463
23 Concurrency: Part II....1467
23.1 Utility Classes TimeUnit and ThreadLocalRandom....1469
23.2 The Executor Framework....1471
23.3 The Fork/Join Framework....1495
23.4 Writing Thread-Safe Code....1499
23.5 Special-Purpose Synchronizers....1518
23.6 Synchronized Collections and Maps....1525
23.7 Concurrent Collections and Maps....1530
Review Questions....1552
24 Database Connectivity....1559
24.1 Introduction to Relational Databases....1560
24.2 Introduction to JDBC....1565
24.3 Establishing a Database Connection....1567
24.4 Creating and Executing SQL Statements....1570
24.5 Processing Query Results....1581
24.6 Customizing Result Sets....1587
24.7 Discovering Database and ResultSet Metadata....1591
24.8 Implementing Transaction Control....1593
Review Questions....1596
25 Annotations....1603
25.1 Basics of Annotations....1605
25.2 Declaring Annotation Types....1606
25.3 Applying Annotations....1611
25.4 Meta-Annotations....1615
25.5 Selected Standard Annotations....1625
25.6 Processing Annotations....1635
Review Questions....1641
26 Secure Coding....1647
26.1 Application Security Overview....1648
26.2 Security Threat Categories....1650
26.3 Java Security Policies....1656
26.4 Additional Security Guidelines....1658
Review Questions....1659
A Taking the Java SE 17 and Java SE 11 Developer Exams....1663
A.1 Preparing for the Exam....1663
A.2 Registering for the Online Proctored Exam....1664
A.3 How the Online Proctored Exam Is Conducted....1666
A.4 The Questions....1667
B Exam Topics: Java SE 17 Developer....1671
C Exam Topics: Java SE 11 Developer....1677
D Annotated Answers to Review Questions....1683
E Mock Exam: Java SE 17 Developer....1757
F Annotated Answers to Mock Exam....1785
G Java Logging API Overview....1795
G.1 Purpose of the Logging API....1795
G.2 Configuring Logging....1796
G.3 Writing Log Messages....1797
G.4 Applying Guarded Logging....1799
G.5 Summary....1799
Index....1801
A....1802
B....1805
C....1807
D....1812
E....1815
F....1817
G....1819
H....1819
I....1820
J....1823
K....1824
L....1825
M....1827
N....1830
O....1832
P....1834
Q....1837
R....1838
S....1840
T....1846
U....1849
V....1850
W....1851
X....1851
Y....1851
Z....1851
A comprehensive guide to the Java programming language and the Java SE 11 and Java SE 17 Developer certification exams, this complete reference contains so much information, we had to split the print edition into two volumes for ease of use. This two-volume set features exhaustive coverage of all the Java language features and APIs covered by the exam objectives. Both volumes of this print edition are included in your purchase and are not sold separately.
OCP Oracle Certified Professional Java SE 17 Developer (Exam 1Z0-829) Programmer's Guide is a unique guide that combines a rigorous introduction to programming in Java with meticulous coverage of the Java SE 17 and Java SE 11 Developer exam objectives. Fully updated to reflect changes in the latest exams, it features an increased focus on analyzing code scenarios--not just individual language constructs. Each objective is thoroughly addressed, reflecting the latest features and APIs, as well as best practices for taking the exam. The only book anyone needs to study for Java SE 17 Developer or Java SE 11 Developer certification. Book features include: