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