OCP Oracle Certified Professional Java SE 21 Developer Study Guide - Jeanne Boyarsky - E-Book

OCP Oracle Certified Professional Java SE 21 Developer Study Guide E-Book

Jeanne Boyarsky

0,0
50,99 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.
Mehr erfahren.
Beschreibung

Unlock your Java potential and master the OCP Java SE 21 Developer exam with confidence

Dive into the OCP Oracle Certified Professional Java SE 21 Developer Study Guide: Exam 1Z0-830 for a comprehensive journey through the Java SE 21 Developer certification exam. Crafted by a team of seasoned Java professionals, this guide not only prepares you for the 1Z0-830 exam but also equips you with essential skills for both new and existing Java development roles. Enhance your knowledge, refine your skills, and discover new techniques with this expertly written roadmap.

Explore the depths of Java development, from writing methods that utilize pattern matching to building applications with virtual threads. This guide covers all you need to ace the certification and excel in your Java development career. Additionally, it provides exclusive access to Sybex's online learning environment and test bank, featuring a wealth of practice questions, electronic flashcards, and a glossary to ensure you're fully prepared for exam day.

You'll also:

  • Gain a solid understanding of Java SE 21 features and how to apply them effectively in your development projects
  • Boost your preparation with hundreds of practice questions and valuable online resources from the Sybex online learning environment
  • Quickly reference key concepts thanks to a searchable glossary, making it an indispensable tool for both junior and senior Java developers

Whether you're gearing up for the OCP Java SE 21 Developer exam or seeking to solidify your Java expertise, this study guide is an essential resource. It not only serves as a comprehensive preparatory material for the certification but also as a go-to reference for your daily programming needs. Embrace this opportunity to reduce test anxiety, enhance your Java skills, and step confidently into your role as a Java developer. Make this book your coding companion today and set the stage for a thriving career in Java development.

Sie lesen das E-Book in den Legimi-Apps auf:

Android
iOS
von Legimi
zertifizierten E-Readern

Seitenzahl: 1588

Veröffentlichungsjahr: 2024

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Table of Contents

Cover

Table of Contents

Title Page

Copyright

Dedication

Acknowledgments

About the Authors

About the Technical Editor

About the Technical Proofreader

Introduction

Understanding the Exam

Reading This Book

Studying for the Exam

Applying Test-Taking Strategies

Taking the Exam

Objective Map

How to Contact the Publisher

Assessment Test

Answers to Assessment Test

Chapter 1: Building Blocks

Learning About the Environment

Understanding the Class Structure

Writing a

main()

Method

Understanding Package Declarations and Imports

Creating Objects

Understanding Data Types

Declaring Variables

Initializing Variables

Managing Variable Scope

Destroying Objects

Summary

Exam Essentials

Review Questions

Chapter 2: Operators

Understanding Java Operators

Applying Unary Operators

Working with Binary Arithmetic Operators

Assigning Values

Comparing Values

Making Decisions with the Ternary Operator

Summary

Exam Essentials

Review Questions

Chapter 3: Making Decisions

Creating Decision-Making Statements

Building

switch

Statements and Expressions

Writing

while

Loops

Constructing

for

Loops

Controlling Flow with Branching

Summary

Exam Essentials

Review Questions

Chapter 4: Core APIs

Creating and Manipulating Strings

Using the

StringBuilder

Class

Understanding Equality

Understanding Arrays

Calculating with Math APIs

Working with Dates and Times

Summary

Exam Essentials

Review Questions

Chapter 5: Methods

Designing Methods

Declaring Local and Instance Variables

Working with Varargs

Applying Access Modifiers

Accessing Static Data

Passing Data among Methods

Overloading Methods

Summary

Exam Essentials

Review Questions

Chapter 6: Class Design

Understanding Inheritance

Creating Classes

Declaring Constructors

Initializing Objects

Inheriting Members

Creating Abstract Classes

Creating Immutable Objects

Summary

Exam Essentials

Review Questions

Chapter 7: Beyond Classes

Implementing Interfaces

Working with Enums

Sealing Classes

Encapsulating Data with Records

Creating Nested Classes

Understanding Polymorphism

Summary

Exam Essentials

Review Questions

Chapter 8: Lambdas and Functional Interfaces

Writing Simple Lambdas

Coding Functional Interfaces

Using Method References

Working with Built-in Functional Interfaces

Working with Variables in Lambdas

Summary

Exam Essentials

Review Questions

Chapter 9: Collections and Generics

Using Common Collection APIs

Using the

List

Interface

Using the

Set

Interface

Using the

Queue

and

Deque

Interfaces

Using the

Map

Interface

Sorting Data

Introducing Sequenced Collections

Reviewing Collection Types

Working with Generics

Summary

Exam Essentials

Review Questions

Chapter 10: Streams

Returning an

Optional

Using Streams

Working with Primitive Streams

Working with Advanced Stream Pipeline Concepts

Summary

Exam Essentials

Review Questions

Chapter 11: Exceptions and Localization

Understanding Exceptions

Recognizing Exception Classes

Handling Exceptions

Automating Resource Management

Formatting Values

Supporting Internationalization and Localization

Loading Properties with Resource Bundles

Summary

Exam Essentials

Review Questions

Chapter 12: Modules

Introducing Modules

Creating and Running a Modular Program

Updating Our Example for Multiple Modules

Diving into the Module Declaration

Creating a Service

Discovering Modules

Comparing Types of Modules

Migrating an Application

Summary

Exam Essentials

Review Questions

Chapter 13: Concurrency

Introducing Threads

Creating Threads with the Concurrency API

Writing Thread-Safe Code

Using Concurrent Collections

Identifying Threading Problems

Working with Parallel Streams

Summary

Exam Essentials

Review Questions

Chapter 14: I/O

Referencing Files and Directories

Operating on

File

and

Path

Introducing I/O Streams

Reading and Writing Files

Serializing Data

Interacting with Users

Working with Advanced APIs

Review of Key APIs

Summary

Exam Essentials

Review Questions

Appendix: Answers to Review Questions

Chapter 1: Building Blocks

Chapter 2: Operators

Chapter 3: Making Decisions

Chapter 4: Core APIs

Chapter 5: Methods

Chapter 6: Class Design

Chapter 7: Beyond Classes

Chapter 8: Lambdas and Functional Interfaces

Chapter 9: Collections and Generics

Chapter 10: Streams

Chapter 11: Exceptions and Localization

Chapter 12: Modules

Chapter 13: Concurrency

Chapter 14: I/O

Index

End User License Agreement

List of Tables

Chapter 1

TABLE 1.1 Setup procedure by operating system

TABLE 1.2 Important

javac

options

TABLE 1.3 Important

java

options

TABLE 1.4 Order for declaring a class

TABLE 1.5 Primitive types

TABLE 1.6 Wrapper classes

TABLE 1.7 Text block formatting

TABLE 1.8 Reserved words

TABLE 1.9 Tracking scope by block

Chapter 2

TABLE 2.1 Order of operator precedence

TABLE 2.2 Unary operators

TABLE 2.3 Increment and decrement operators

TABLE 2.4 Binary arithmetic operators

TABLE 2.5 Simple assignment operator

TABLE 2.6 Compound assignment operators

TABLE 2.7 Equality operators

TABLE 2.8 Relational operators

TABLE 2.9 Logical operators

TABLE 2.10 Bitwise operators

TABLE 2.11 Conditional operators

Chapter 3

TABLE 3.1 Supported control statement features

Chapter 4

TABLE 4.1 Rules for

indent()

and

stripIndent()

TABLE 4.2 Common formatting symbols

TABLE 4.3 Binary search rules

TABLE 4.4

Arrays.compare()

examples

TABLE 4.5 Equality vs. comparison vs. mismatch

TABLE 4.6 Methods in

LocalDate

,

LocalTime

,

LocalDateTime

, and

ZonedDateTime

...

TABLE 4.7 Conversion methods in

LocalDate

,

LocalTime

, and

LocalDateTime

TABLE 4.8 Where to use

Duration

and

Period

Chapter 5

TABLE 5.1 Parts of a method declaration in Figure 5.1

TABLE 5.2 Optional specifiers for methods

TABLE 5.3 Optional specifiers for instance variables

TABLE 5.4 A method in ______ can access a ______ member.

TABLE 5.5 Static vs. instance calls

TABLE 5.6 The order that Java uses to choose the right overloaded method

Chapter 6

TABLE 6.1 Class modifiers

Chapter 7

TABLE 7.1 Interface member types

TABLE 7.2 Interface member access

TABLE 7.3 Usage of the

permits

clause in sealed classes

TABLE 7.4 Modifiers in nested classes

TABLE 7.5 Nested class access rules

Chapter 8

TABLE 8.1 Valid lambdas that return a

boolean

TABLE 8.2 Invalid lambdas that should return a

boolean

TABLE 8.3 Method references

TABLE 8.4 Common functional interfaces

TABLE 8.5 Convenience methods

TABLE 8.6 Common functional interfaces for primitives

TABLE 8.7 Primitive-specific functional interfaces

TABLE 8.8 Rules for accessing a variable from a lambda body inside a method...

Chapter 9

TABLE 9.1 Factory methods to create a

List

TABLE 9.2

List

methods

TABLE 9.3

Queue

methods

TABLE 9.4

Deque

methods

TABLE 9.5 Using a

Deque

as a stack

TABLE 9.6

Map

methods

TABLE 9.7 Behavior of the

merge()

method

TABLE 9.8 Comparison of

Comparable

and

Comparator

TABLE 9.9 Helper static methods for building a

Comparator

TABLE 9.10 Helper default methods for building a

Comparator

TABLE 9.11

SequencedCollection

Methods

TABLE 9.12 Common

SequencedMap

Methods

TABLE 9.13 Java Collections Framework types

TABLE 9.14 Collection classes

TABLE 9.15 Types of bounds

TABLE 9.16 Why we need a lower bound

Chapter 10

TABLE 10.1 Common

Optional

instance methods

TABLE 10.2 Intermediate vs. terminal operations

TABLE 10.3 Creating a source

TABLE 10.4 Terminal stream operations

TABLE 10.5 Common primitive stream methods

TABLE 10.6 Mapping methods between types of streams

TABLE 10.7 Function parameters when mapping between types of streams

TABLE 10.8 Optional types for primitives

TABLE 10.9 Advanced

Optional

instance methods

TABLE 10.10 Examples of grouping/partitioning collectors

TABLE 10.11

Spliterator

methods

Chapter 11

TABLE 11.1 Types of exceptions and errors

TABLE 11.2 Unchecked exceptions

TABLE 11.3 Checked exceptions

TABLE 11.4 Errors

TABLE 11.5

DecimalFormat

symbols

TABLE 11.6 Common date/time symbols

TABLE 11.7 Supported date/time symbols

TABLE 11.8 Factory methods to get a

NumberFormat

TABLE 11.9 Factory methods to get a

DateTimeFormatter

TABLE 11.10

Locale.Category

values

TABLE 11.11 Picking a resource bundle for French/France with default locale ...

TABLE 11.12 Selecting resource bundle properties

Chapter 12

TABLE 12.1 Options you need to know for using modules with

javac

TABLE 12.2 Options you need to know for using modules with

java

TABLE 12.3 Access control with modules

TABLE 12.4 Reviewing services

TABLE 12.5 Reviewing directives

TABLE 12.6 Common modules

TABLE 12.7 Java modules prefixed with

java

TABLE 12.8 Java modules prefixed with

jdk

TABLE 12.9 Modes using

jmod

TABLE 12.10 Comparing command-line operations

TABLE 12.11 Options you need to know for the exam:

javac

TABLE 12.12 Options you need to know for the exam:

java

TABLE 12.13 Options you need to know for the exam:

jar

TABLE 12.14 Options you need to know for the exam:

jdeps

TABLE 12.15 Options you need to know for the exam:

jlink

TABLE 12.16 Options you need to know for the exam:

jpackage

TABLE 12.17 Practicing with automatic module names

TABLE 12.18 Properties of module types

TABLE 12.19 Comparing migration strategies

Chapter 13

TABLE 13.1 Creating and starting a

Thread

TABLE 13.2 Java thread terminology

TABLE 13.3

ExecutorService

methods

TABLE 13.4

Future

methods

TABLE 13.5

TimeUnit

values

TABLE 13.6

ExecutorService

states

TABLE 13.7

ScheduledExecutorService

methods

TABLE 13.8

Executors

factory methods

TABLE 13.9 Atomic classes

TABLE 13.10 Common atomic methods

TABLE 13.11

Lock

methods

TABLE 13.12 Concurrent collection classes

TABLE 13.13 Synchronized

Collections

methods

Chapter 14

TABLE 14.1 File system symbols

TABLE 14.2 Common

File

and

Path

operations

TABLE 14.3 Common

File

and

Files

operations

TABLE 14.4 Common NIO.2 method arguments

TABLE 14.5

Path

API

TABLE 14.6 The

java.io

abstract stream base classes

TABLE 14.7 The

java.io

concrete I/O stream classes

TABLE 14.8 Common I/O read and write instance methods

TABLE 14.9 Common

Files

NIO.2 read and write

static

methods

TABLE 14.10 Common I/O stream methods

TABLE 14.11 The attributes and view types

TABLE 14.12 Walking a directory with a cycle using breadth-first search

TABLE 14.13 Key APIs

List of Illustrations

Introduction

FIGURE I.1 Tracking objects and references

Chapter 1

FIGURE 1.1 Compiling with packages

FIGURE 1.2 Compiling with packages and directories

FIGURE 1.3 Text block

FIGURE 1.4 Your drawing after line 5

FIGURE 1.5 Your drawing after line 7

Chapter 2

FIGURE 2.1 Java operation

FIGURE 2.2 The logical truth tables for

&

,

|

, and

^

Chapter 3

FIGURE 3.1 The structure of an

if

statement

FIGURE 3.2 The structure of an

else

statement

FIGURE 3.3 Pattern matching with

if

FIGURE 3.4 A

switch

statement

FIGURE 3.5 A

switch

expression

FIGURE 3.6 A

switch

expression with a

case

block and

yield

statement

FIGURE 3.7 Pattern matching with

switch

FIGURE 3.8 The structure of a

while

statement

FIGURE 3.9 The structure of a

do

/

while

statement

FIGURE 3.10 The structure of a basic

for

loop

FIGURE 3.11 The structure of an enhanced for-each loop

FIGURE 3.12 The structure of a

break

statement

FIGURE 3.13 The structure of a

continue

statement

Chapter 4

FIGURE 4.1 Indexing for a string

FIGURE 4.2 Indexes for a substring

FIGURE 4.3 The basic structure of an array

FIGURE 4.4 An empty array

FIGURE 4.5 An initialized array

FIGURE 4.6 An array pointing to strings

FIGURE 4.7 A sparsely populated array of arrays

FIGURE 4.8 An asymmetric array of arrays

FIGURE 4.9 Period format

FIGURE 4.10 How daylight saving time works

Chapter 5

FIGURE 5.1 Method declaration

FIGURE 5.2 Classes used to show

private

and package access

FIGURE 5.3 Classes used to show

protected

access

FIGURE 5.4 Copying a reference with pass-by-value

Chapter 6

FIGURE 6.1 Subclass and superclass declarations

FIGURE 6.2 Types of inheritance

FIGURE 6.3 Java object inheritance

Chapter 7

FIGURE 7.1 Defining an interface

FIGURE 7.2 Implementing an interface

FIGURE 7.3 Interface Inheritance

FIGURE 7.4 Defining a simple enum

FIGURE 7.5 Defining a sealed class

FIGURE 7.6 Defining a record

FIGURE 7.7 Declaring a compact constructor

FIGURE 7.8 Object versus reference

Chapter 8

FIGURE 8.1 Lambda syntax omitting optional parts

FIGURE 8.2 Lambda syntax including optional parts

Chapter 9

FIGURE 9.1 Java Collections Framework

FIGURE 9.2 Example of a

List

FIGURE 9.3 Example of a

Set

FIGURE 9.4 Examples of Sets

FIGURE 9.5 Example of a

Deque

FIGURE 9.6 Working with a

Deque

FIGURE 9.7 Working with a stack

FIGURE 9.8 Example of a

Map

Chapter 10

FIGURE 10.1

Optional

FIGURE 10.2 Stream pipeline

FIGURE 10.3 Steps in running a stream pipeline

FIGURE 10.4 A stream pipeline with a limit

FIGURE 10.5 Stream pipeline with multiple intermediate operations

Chapter 11

FIGURE 11.1 Categories of exception

FIGURE 11.2 The syntax of a

try

statement

FIGURE 11.3 The syntax of a multi-catch block

FIGURE 11.4 The syntax of a

try

statement with

finally

FIGURE 11.5 The syntax of a basic try-with-resources statement

FIGURE 11.6

Locale

formats

Chapter 12

FIGURE 12.1 Design of a modular system

FIGURE 12.2 Looking inside a module

FIGURE 12.3 Contents of

zoo.animal.feeding

FIGURE 12.4 Module

zoo.animal.feeding

directory structure

FIGURE 12.5 Running a module using

java

FIGURE 12.6 Modules depending on

zoo.animal.feeding

FIGURE 12.7 Contents of

zoo.animal.care

FIGURE 12.8 Dependencies for

zoo.animal.talks

FIGURE 12.9 Contents of

zoo.animal.talks

FIGURE 12.10 Contents of

zoo.staff

FIGURE 12.11 Dependencies for

zoo.staff

FIGURE 12.12 Transitive dependency version of our modules

FIGURE 12.13 Modules in the tour application

FIGURE 12.14 Determining the order

FIGURE 12.15 Determining the order when not unique

FIGURE 12.16 Bottom-up migration

FIGURE 12.17 Top-down migration

FIGURE 12.18 First attempt at decomposition

FIGURE 12.19 Removing the cyclic dependencies

Chapter 13

FIGURE 13.1 Platform threads

FIGURE 13.2 Virtual threads

FIGURE 13.3 Thread states

FIGURE 13.4 Thread Executor Lifecycle

FIGURE 13.5 Lack of thread synchronization

FIGURE 13.6 Thread synchronization using atomic operations

FIGURE 13.7 Race condition on user creation

Chapter 14

FIGURE 14.1 Directory and file hierarchy

FIGURE 14.2 Relative paths using path symbols

FIGURE 14.3 Comparing file uniqueness

FIGURE 14.4 Visual representation of an I/O stream

FIGURE 14.5 Serialization process

FIGURE 14.6 File system with cycle

FIGURE 14.7 Diagram of I/O stream classes

Guide

Cover

Table of Contents

Title Page

Copyright

Dedication

Acknowledgments

About the Author

About the Technical Editor

Introduction

Assessment Test

Begin Reading

Appendix: Answers to Review Questions

Index

End User License Agreement

Pages

iii

iv

v

vii

ix

xi

xxix

xxx

xxxi

xxxii

xxxiii

xxxiv

xxxv

xxxvi

xxxvii

xxxviii

xxxix

xl

xli

xlii

xliii

xliv

xlv

xlvi

xlvii

xlviii

xlix

l

li

lii

liii

liv

lv

lvi

lvii

lviii

lix

lx

lxi

lxii

lxiii

lxiv

lxv

lxvi

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216

217

218

219

220

221

222

223

224

225

226

227

228

229

230

231

233

234

235

236

237

238

239

240

241

242

243

244

245

246

247

248

249

250

251

252

253

254

255

256

257

258

259

260

261

262

263

264

265

266

267

268

269

270

271

272

273

274

275

276

277

278

279

280

281

282

283

284

285

286

287

288

289

291

292

293

294

295

296

297

298

299

300

301

302

303

304

305

306

307

308

309

310

311

312

313

314

315

316

317

318

319

320

321

322

323

324

325

326

327

328

329

330

331

332

333

334

335

336

337

338

339

340

341

342

343

344

345

346

347

348

349

350

351

352

353

354

355

356

357

359

360

361

362

363

364

365

366

367

368

369

370

371

372

373

374

375

376

377

378

379

380

381

382

383

384

385

386

387

388

389

390

391

392

393

394

395

396

397

398

399

400

401

402

403

404

405

406

407

408

409

410

411

412

413

414

415

416

417

418

419

420

421

422

423

424

425

426

427

428

429

430

431

432

433

434

435

436

437

439

440

441

442

443

444

445

446

447

448

449

450

451

452

453

454

455

456

457

458

459

460

461

462

463

464

465

466

467

468

469

470

471

472

473

474

475

476

477

478

479

480

481

482

483

484

485

486

487

488

489

490

491

492

493

494

495

496

497

498

499

500

501

502

503

504

505

506

507

508

509

510

511

512

513

514

515

516

517

518

519

520

521

522

523

524

525

526

527

528

529

530

531

532

533

534

535

536

537

538

539

540

541

542

543

544

545

546

547

548

549

550

551

552

553

554

555

556

557

558

559

560

561

562

563

564

565

566

567

568

569

570

571

572

573

574

575

576

577

578

579

580

581

582

583

584

585

586

587

588

589

590

591

592

593

594

595

596

597

598

599

600

601

602

603

604

605

606

607

608

609

610

611

612

613

614

615

616

617

618

619

620

621

622

623

624

625

626

627

628

629

630

631

632

633

634

635

636

637

638

639

640

641

642

643

644

645

646

647

648

649

650

651

652

653

654

655

656

657

658

659

660

661

662

663

664

665

666

667

668

669

670

671

672

673

674

675

676

677

678

679

680

681

683

684

685

686

687

688

689

690

691

692

693

694

695

696

697

698

699

700

701

702

703

704

705

706

707

708

709

710

711

712

713

714

715

716

717

718

719

720

721

722

723

724

725

726

727

728

729

730

731

732

733

734

735

736

737

738

739

740

741

742

743

745

746

747

748

749

750

751

752

753

754

755

756

757

758

759

760

761

762

763

764

765

766

767

768

769

770

771

772

773

774

775

776

777

778

779

780

781

782

783

784

785

786

787

788

789

790

791

792

793

794

795

796

797

798

799

800

801

802

803

804

805

806

807

808

809

811

812

813

814

815

816

817

818

819

820

821

822

823

824

825

826

827

828

829

830

831

832

833

834

835

836

837

838

839

840

841

842

843

844

845

846

847

848

849

850

851

852

853

854

855

856

857

858

859

860

861

862

863

864

865

866

867

868

869

870

871

872

873

874

875

876

877

878

879

880

881

882

883

884

885

887

888

889

890

891

892

893

894

895

896

897

898

899

900

901

902

903

904

905

906

907

908

909

910

911

912

913

914

915

916

917

918

919

920

921

922

923

924

925

926

927

928

929

930

931

932

933

934

935

936

937

938

939

940

941

942

943

944

945

946

947

948

949

950

951

952

953

954

955

956

957

958

959

960

961

962

963

964

965

966

967

968

969

970

971

972

974

975

OCPOracle® Certified Professional Java® SE 21 DeveloperStudy Guide

Exam 1Z0-830

Jeanne Boyarsky

Scott Selikoff

 

Copyright © 2025 by John Wiley & Sons, Inc. All rights, including for text and data mining, AI training, and similar technologies, are reserved.

Published by John Wiley & Sons, Inc., Hoboken, New Jersey.Published simultaneously in Canada and the United Kingdom.

ISBNs: 9781394286614 (paperback), 9781394286638 (ePDF), 9781394286621 (ePub)

No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning, or otherwise, except as permitted under Section 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, Inc., 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 750-4470, or on the web at www.copyright.com. Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-6008, or online at www.wiley.com/go/permission.

Trademarks: WILEY, the Wiley logo, and the Sybex logo are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates, in the United States and other countries, and may not be used without written permission. Oracle and Java are trademarks or registered trademarks of Oracle America, Inc. All other trademarks are the property of their respective owners. John Wiley & Sons, Inc. is not associated with any product or vendor mentioned in this book.

Limit of Liability/Disclaimer of Warranty: While the publisher and authors have used their best efforts in preparing this book, they make no representations or warranties with respect to the accuracy or completeness of the contents of this book and specifically disclaim any implied warranties of merchantability or fitness for a particular purpose. No warranty may be created or extended by sales representatives or written sales materials. The advice and strategies contained herein may not be suitable for your situation. You should consult with a professional where appropriate. Further, readers should be aware that websites listed in this work may have changed or disappeared between when this work was written and when it is read. Neither the publisher nor authors shall be liable for any loss of profit or any other commercial damages, including but not limited to special, incidental, consequential, or other damages.

For general information on our other products and services, please contact our Customer Care Department within the United States at (800) 762-2974, outside the United States at (317) 572-3993. For product technical support, you can find answers to frequently asked questions or reach us via live chat at https://sybexsupport.wiley.com.

Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic formats. For more information about Wiley products, visit our web site at www.wiley.com.

Library of Congress Control Number: 2024941967

Cover image: © Jeremy Woodhouse/Getty ImagesCover design: Wiley

 

 

 

To the GearMasters (FIRST Tech Challenge Team 8365) 2014–2024. You inspired me and so many others!

—Jeanne

 

For my daughter, Elysia, your intelligence, sense of humor, endless energy, and perseverance make you a force to be reckoned with. May you continue to grow into the powerful woman I know you’re destined to be.

—Scott

Acknowledgments

Jeanne and Scott would like to thank numerous individuals for their contributions to this book. Thank you to Caroline Define and Archana Pragash for guiding us through the process and making the book better in many ways. Thank you to Janeice DelVecchio for being our technical editor as we wrote this book. Janeice pointed out many subtle errors in addition to the big ones. Thank you to Elena Felder for being our technical proofreader and finding the errors that we managed to sneak by Janeice. And a special thank-you to our copy editor Kim Wimpsett for finding subtle errors that everyone (including us!) missed. This book also wouldn’t be possible without many people at Wiley, including Kenyon Brown, Pete Gaughan, Ashirvad Moses, and many others.

Jeanne would personally like to thank Dani, Janeice, Kim, Norm, Scott, and Shweta during a difficult month that overlapped with book writing. She also wants to thank Victor for his patience as Jeanne worked on two books simultaneously. (this one and Real-World Java: Helping You Navigate the Java Ecosystem). A big thank-you to Scott for being a great co-author while honoring Jeanne’s request to not think about the book until FIRST Robotics Championships was over. A big thank-you to everyone at CodeRanch.com who asked and responded to questions and comments about our books. Finally, Jeanne would like to thank all of the new programmers at CodeRanch.com and FIRST robotics teams FRC 694 and FTC 310/479 for the constant reminders of how new programmers think.

Scott could not have reached this point without his wife, Patti, and family, whose love and support make this book possible. He would like to thank his twin daughters, Olivia and Sophia, and youngest daughter, Elysia, for their patience and understanding and bringing Daddy a cup of cappuccino when it was “time for Daddy to work in his office!” Scott would like to extend his gratitude to his wonderfully patient co-author, Jeanne, on this, their tenth book. He doesn’t know how she puts up with him, but he’s glad she does and is thrilled at the quality of books we produce. Finally, Scott would like to thank his mother, Barbara Selikoff (a retired teacher), for teaching him the value of education, and his father, Mark Selikoff, for instilling in him the benefits of working hard.

Both of us would like to give a big thank-you to the readers of our books. Hearing from all of you who enjoyed the book and passed the exam is a great feeling. We appreciate the 7Up sorting tip from Anil Philip that you’ll see in the book along with Venkat Subramaniam for the restaurant analogy for concurrency. We’d also like to thank those who pointed out errors and made suggestions for improvements to the Java 17 book. As of July 2024, the top two were Guillaume Bailly and Albert Attard.

About the Authors

Jeanne Boyarsky was selected as a Java Champion in 2019 and is a leader of the NYJavaSIG. She has worked as a Java developer for more than 22 years at a bank in New York City where she develops, mentors, and conducts training. Besides being a senior moderator at CodeRanch.com in her free time, she works on the forum code base. Jeanne also mentors the programming division of a FIRST robotics team, where she works with students just getting started with Java. She also speaks at several conferences each year.

Jeanne got her bachelor’s degree in 2002 and her master’s degree in computer information technology in 2005. She enjoyed getting her master’s degree in an online program while working full time. This was before online education was cool! Jeanne is also a Distinguished Toastmaster and a Scrum Master. You can find out more about Jeanne at www.jeanneboyarsky.com and follow her on social media at x.com/jeanneboyarsky or mastodon.social/@jeanneboyarsky.

Scott Selikoff is a professional software developer and author with almost 25 years of experience developing full-stack database-driven systems. Skilled in a plethora of software languages and platforms, Scott currently works as a staff software engineer at Google, specializing in architecture and cloud services.

A native of Toms River, New Jersey, Scott earned his bachelor’s degree from Cornell University in mathematics and computer science in 2002 after three years of study. In 2003, he received his master’s degree in computer science, also from Cornell University. As someone with a deep love of education, Scott has always enjoyed teaching others new concepts. Scott is a leader of the Garden State Java User Group, helping to facilitate discussions and exchange of ideas within the community. He has also taught lectures at multiple universities and conferences.

Scott lives in New Jersey with his loving wife, Patti; three amazing daughters, twins Olivia and Sophia and little Elysia; a very playful dog, Georgette; and three silly cats, Snowball, Sugar, and Minnie Mouse. In his spare time, he plays violin in the Toms River Multigenerational Orchestra. You can find out more about Scott at www.linkedin.com/in/selikoff or follow him on social media at x.com/ScottSelikoff.

Jeanne and Scott are both moderators on the CodeRanch.com forums and can be reached there for question and comments. They also co-author a technical blog called Down Home Country Coding at www.selikoff.net.

In addition to this book, Jeanne and Scott are the authors of nine best-selling Java books:

OCP Java 17 Practice Tests

(Sybex, 2022)

OCP Java 17 Developer Study Guide

(Sybex, 2022)

OCP Java 11 Practice Tests

(Sybex, 2021)

OCP Java 11 Developer Complete Study Guide

(Sybex, 2020)

OCP Java 11 Programmer II Study Guide

(Sybex, 2020)

OCP Java 11 Programmer I Study Guide

(Sybex, 2019)

OCA/OCP Java 8 Practice Tests

(Sybex, 2017)

OCP: Java 8 Programmer II Study Guide

(Sybex, 2016)

OCA: Java 8 Programmer I Study Guide

(Sybex, 2015)

About the Technical Editor

Janeice DelVecchio has been a professional Software Developer for 14 years, and has had a lifelong love of programming and computers. Editing technical books is a fun task for her because she likes finding and fixing defects of all types.

In her day job she uses a very broad range of skills with technologies including cloud computing, process automation, advanced unit testing and devops. She also volunteers at CodeRanch.com where she runs the Java class known as the Cattle Drive.

She is an expert with the Java programming language. If you ask her which language is the best, she will tell you that languages are tools and to pick the one that fits your use case. The first language she learned was BASIC, and one day she hopes to learn gaming development.

In her spare time, she enjoys cooking, solving puzzles, and playing video games. She loves eating sushi, drinking craft beer, and petting dogs—her guilty pleasure is 80’s pop music. She lives in Litchfield County, Connecticut with her dog, Desmond and her cat, Suki.About the Technical Proofreader

About the Technical Proofreader

Elena Felder got into Java development back when the language lacked even generics, and has been delighted that the language, its tooling and community have continued to grow and adapt to successfully keep up with the ever-changing world.

Elena got into proofreading Jeanne and Scott’s books because one day a very long time ago she got Jeanne to spend way longer than planned revising a single slide on lambda syntax by pointing out everything that could go wrong, which then lead to proofreading one of Jeanne and Scott’s first Java 8 certification book chapters for fun (as one does). She’s been proofreading the Wiley Java certification books professionally ever since.

After 20 years of real-world Java experience, including four years of maintaining Google Cloud’s Spring Framework integrations, Elena switched to writing code and chasing bugs in what feels like every language imaginable. Java, however, remains a personal favorite!

Currently Elena leads the ecosystem integrations team at MotherDuck, a DuckDB-powered serverless data warehouse.

She lives in Brooklyn, NY with her husband, two children, two cats, and countless plants.