ocp_oracle_certified_professional_java_se_17_developer_study_guide_index

OCP Oracle Certified Professional Java SE 17 Developer Study Guide Index

A

advanced stream pipeline concepts chaining Optionals, 566–568

collecting results, 570–578

linking streams to underlying data, 565–566

using Spliterator, 569–570

allMatch() method, 544

anonymous classes about, 382

defining, 389–390

anyMatch() method, 544

append() method, 172–173

appending values, 172–173

application programming interfaces (APIs). See also core APIs about, 3, 464–465

adding data, 466

advanced file attributes, 840–843

manipulating input streams, 838–839

searching directories, 847–848

traversing directory trees, 843–847

checking contents, 468

clearing collections, 467–468

collection about, 464–465

adding data, 466

checking contents, 468

clearing collections, 467–468

counting elements, 467

determining equality, 470

iterating, 469

removing data, 466–467

removing with conditions, 468–469

using diamond operator (<>), 465–466

Concurrency API, creating threads with increasing concurrency with pools, 739–740

scheduling tasks, 737–739

shutting down thread executors, 731–732

single-thread executor, 730–731

submitting tasks, 732–733

waiting for results, 733–736

counting elements, 467

determining equality, 470

iterating, 469

Java Persistence API (JPA), 865

key, 848–850

logging, 833

removing data, 466–467

removing with conditions, 468–469

transaction, 895

using diamond operator (<>), 465–466

applications, migrating about, 704–705

bottom-up migration strategy, 706–707

cyclic dependency, 709–711

determining order, 705–706

splitting big projects into modules, 709

top-down migration strategy, 707–708

applying access modifiers about, 235

package access, 236–237

private access, 235–236

protected access, 237–241

public access, 242

reviewing access modifiers, 242–243

case blocks, 118–120

casting, 79–80

class access modifiers, 282–283

multi-catch blocks, 609–611

records, 375–377

ReentrantLock class, 747–748

resource management, 620–621

scope to classes, 47

Serializable interface, 825–826

switch statements about, 110

switch expression, 115–121

switch statement, 110–115

arithmetic operators about, 72–73

adding parentheses, 73–74

division, 74–75

modulus, 74–75

ArithmeticException, 601

ArrayIndexOutOfBoundsException, 602

ArrayList, 472–474

arrays about, 178, 261

comparing, 185–187

converting List to, 476–477

creating arrays of primitives, 179–180

creating arrays with reference variables, 180–182

multidimensional, 188–190

searching, 184–185

sorting, 183–184

using, 182–183

using methods with varargs, 187–188

arrow operator (→), 69

assigning lambdas to var, 425

values assignment operator, 77

casting values, 77–81

compound assignment operators, 81–82

return value of assignment operators, 82–83

assignment operators about, 77

return value of, 82–83

@FunctionalInterface annotation, 426

atomic classes, protecting data with, 742–744

@Override annotation, 310

attributes (file), 840–843

autoboxing about, 261

variables, 256–257

automatic modules, 701–703

automating resource management about, 615

applying effectively final, 620–621

suppressed exceptions, 621–624

try-with-resources, 615–620

available() method, 830

awaitTermination() method, 736

B

backslash (\), 666

Bai, Ying (author) Practical Database Programming with Java, 864

base 10, 29

batching statements, 881–882

BiConsumer, implementing, 436–438

BiFunction, implementing, 439

binary format, 29

binary operators, 72

BinaryOperator, implementing, 440–441

binarySearch() method, 501–502

bind variables defined, 878

using, 887

BiPredicate, implementing, 438–439

bit, 813

bitwise complement operator (), 70

bitwise operators, 87–88

blocks, 102–103

boilerplate code, 106

bookmarking, with savepoints, 894

boolean type about, 114

functional interfaces for, 444

bottom-up migration strategy, 706–707

bounded parameter types, 512

bounding generic types, 512–517

boxed() method, 563

braces ({}) about, 24–25, 45

indentation and, 104

branching about, 139

controlling flow with about, 131

adding optional labels, 132

branching, 139

break statement, 133–135

continue statement, 135–136

nested loops, 131–132

return statement, 137–138

unreachable code, 138

b[[readth]]-first search, 844

break statement about, 133–135

exiting with, 113–114

built-in functional interfaces about, 434–435

checking, 441–442

implementing BiConsumer, 436–438

BiFunction, 439

BinaryOperator, 440–441

BiPredicate, 438–439

Consumer, 436–438

Function, 439

Predicate, 438–439

Supplier, 435–436

UnaryOperator, 440–441

for primitives, 443–445

using convenience methods on, 442–443

byte streams, 813–814

byte type, 28

C

CallableStatement, calling calling procedures without parameters, 888–889

comparing callable statement parameters, 891

passing IN parameters, 889

returning an OUT parameter, 889–890

using additional options, 891–892

working with INOUT parameters, 890–891

calling abstract methods, 359

basic Map methods, 486

CallableStatement about, 887–888

calling procedures without parameters, 888–889

comparing callable statement parameters, 891

passing IN parameters, 889

returning an OUT parameter, 889–890

using additional options, 891–892

working with INOUT parameters, 890–891

constructors, 22–23, 433

hidden default methods, 356–357

instance methods on objects, 430–431

on parameters, 432

methods that throw [[exceptions, 598–599

with varargs, 233

name() method, 362

ordinal() method, 362

overload constructors with this(), 289–291

parent constructors with super(), 292–296

procedures without parameters, 888–889

static methods, 430

super reference, 284–286

valueOf() method, 363

values() method, 362

camel case, 36

case, adjusting, 161

case blocks, applying, 118–120

case values, combining, 111–112

casting interfaces, 396

objects, 395–396

values, 77–81

variables, 80–81

catch blocks, chaining, 607–609

ceil() method, 191–192

ceiling, determining, 191–192

chaining about, 171

catch blocks, 607–609

Optionals, 566–568

char type, 28

character encoding, 813–814

character streams, 813–814

charAt() method, 159

checkAnswer() method, 40

checked Exception classes, 604–605

checked exceptions, 307–308, 594–595

checking for blank strings, 167

contents of APIs, 468

for empty strings, 167

for equality, 162

functional interfaces, 441–442

parentheses syntax, 74

version of Java, 4

checkTime() method, 358

ChronoUnit, 203

class access modifiers, applying, 282–283

class design about, 276, 326–327

creating abstract classes about, 315–317

creating concrete classes, 318–320

creating constructors in abstract classes, 320–321

declaring abstract methods, 317–318

finding invalid declarations, 321–323

creating classes accessing this reference, 283–284

applying class access modifiers, 282–283

calling super reference, 284–286

extending classes, 281–282

creating immutable objects declaring immutable classes, 323–325

performing defensive copies, 325–326

declaring constructors calling overload constructors with this(), 289–291

calling parent constructors with super(), 292–296

creating constructors, 286–287

default constructor, 287–289

exam essentials, 327–329

inheritance about, 276

class modifiers, 278

declaring subclasses, 276–278

inheriting Object, 279–280

single vs. multiple, 279

inheriting members about, 304–305

hiding static methods, 311–313

hiding variables, 313–314

overriding methods, 305–310

redeclaring private methods, 311

writing final methods, 314

initializing objects initializing classes, 297–298

initializing final fields, 298–300

initializing instances, 300–304

review question answers, 927–932

review questions, 330–344

.class files, creating for inner classes, 384

class keyword, 4–5

class membership, instance membership vs., 245–248

class modifiers, 278

class variables, defining, 41

ClassCastException, 602

classes applying scope to, 47

concurrent, 755–757

ensuring they're Serializable, 827–828

generic, 504–506

initializing, 297–298

inner about, 382

creating .class files for, 384

declaring, 382–386

instantiating instances of, 384

referencing members of, 384–386

loading, 297

ordering elements in, 21–22

sealing about, 367, 401–402

compiling, 368–369

declaring, 367–368

exam essentials, 402–403

interfaces, 372

omitting permits clause, 370–372

review questions, 404–418

rules for, 372–373

specifying subclass modifier, 369–370

structure of about, 4

comments, 5–7

fields and methods, 4–5

source files, 7

classpath, 17–18, 667

clear() method, 467–468

clearing collections on APIs, 467–468

close() method, 621–624, 823–824

closing database resources, 895–897

system streams, 833–834

code of functional interfaces about, 426–427

adding object methods, 427–428

reusing with private interface methods, 358–359

shortening, 106–110

unreachable, 138

code blocks, 24–25

collect() method, 547–549, 570–573, 767, 768

collecting about, 547–549

results, 570–578

collection APIs about, 464–465

adding data, 466

checking contents, 468

clearing collections, 467–468

counting elements, 467

determining equality, 470

iterating, 469

removing data, 466–467

removing with conditions, 468–469

using diamond operator (<>), 465–466

collections and generics about, 519–520

comparing collection types, 490–491

Deque interface about, 479–480

comparing implementations, 480

working with methods, 480–483

exam essentials, 520

List interface about, 471

comparing implementations, 472

converting to arrays, 476–477

creating with constructors, 473–474

creating with factories, 472–473

working with methods, 474–476

Map interface about, 483–484

calling basic methods, 486

comparing implementations, 484

getting values, 487–488

inserting through, 487

merging data, 488–490

putIfAbsent() method, 488

replacing values, 488

working with methods, 484–485

Queue interface about, 479–480

comparing implementations, 480

working with methods, 480–483

review question answers, 939–942

review questions, 521–529

Set interface about, 477

comparing implementations, 477–478

working with methods, 478–479

sorting data about, 492

comparing Comparable and Comparator, 497–498

comparing data with Comparator, 496–497

comparing multiple fields, 498–500

creating Comparable class, 492–496

List, 503

searching and, 500–502

using common collection APIs about, 464–465

adding data, 466

checking contents, 468

clearing collections, 467–468

counting elements, 467

determining equality, 470

iterating, 469

removing data, 466–467

removing with conditions, 468–469

using diamond operator (<>), 465–466

bounded context

working with generics about, 503–504, 517–519

bounding generic types, 512–517

creating generic classes, 504–506

creating generic records, 512

implementing generic interfaces, 509–510

type erasure, 506–508

writing generic methods, 510–511

combiner, 548

combining case values, 111–112

with newBufferedReader() and newBufferedWriter(), 822–823

command-line options, 697–700

comments, 5–7

committing, rolling back and, 892–894

compact constructors, 379

CompactNumberFormat, 635–637

comparator, 184

compare() method, 185–187

compareTo() method, 107, 492–494, 495–496, 500–501

comparing arrays, 185–187

callable statement parameters, 891

collection types, 490–491

Comparable and Comparator, 497–498

data with Comparator, 496–497

equals() and ==, 175–176

files with isSameFile() and mismatch(), 809–811

implementations of List, 472

Map implementations, 484

multiple fields, 498–500

Queue and Dequeue implementations, 480

Set implementations, 477–478

values conditional operators, 88–90

equality operators, 83–84

logical operators, 87–88

relational operators, 84–87

compiling code with packages, 16–18

with JAR files, 20

modules, 666–668, 870

to other directories, 18–19

sealed classes, 368–369

with wildcards, 17

complement operators, 70–71

compound assignment operators, 81–82

compound key, 866

concatenating streams, 551

strings, 157–158

concrete classes, creating, 318–320

concrete methods, declaring, 353–361

concurrency about, 722, 770

creating threads with Concurrency API about, 730

increasing concurrency with pools, 739–740

scheduling tasks, 737–739

shutting down thread executors, 731–732

single-thread executor, 730–731

submitting tasks, 732–733

waiting for results, 733–736

exam essentials, 770–771

identifying threading problems, 758–761

parallel streams about, 761–762

creating, 762

performing parallel decomposition, 762–764

processing parallel reductions, 764–769

review question answers, 951–955

review questions, 772–783

threads about, 722–723

creating threads, 724–725

interrupting, 729–730

managing life cycle of, 727

polling, 727–729

types, 725–726

using concurrent collections concurrent classes, 755–757

memory consistency errors, 754–755

obtaining synchronized collections, 757–758

writing thread-safe code about, 740–741

accessing data with volatile, 741–742

improving access with synchronized block]]s, 744–746

Lock framework, 747–751

orchestrating tasks with CyclicBarrier, 751–754

protecting data with atomic classes, 742–744

synchronizing on methods, 746–747

Concurrency API, creating threads with increasing concurrency with pools, 739–740

scheduling tasks, 737–739

shutting down thread executors, 731–732

single-thread executor, 730–731

submitting tasks, 732–733

waiting for results, 733–736

concurrent classes, 755–757

concurrent collections concurrent classes, 755–757

memory consistency errors, 754–755

obtaining synchronized collections, 757–758

conditional operators, 88–90

conflicting modifiers, 352

conflicts, naming, 15

connecting to databases building URL, 870–871

getting database Connection, 871–873

Console, acquiring input with, 834–837

constructor overloading, 287

constructor parameters, passing, 40

constructor reference, 433

constructors adding, 364–366

calling, 22–23, 433

compact, 379

creating about, 286–287

in abstract classes, 320–321

List with, 473–474

declaring about, 378–381

calling overload constructors with this(), 289–291

calling parent constructors with super(), 292–296

creating constructors, 286–287

default constructor, 287–289

default, 287–289

overloaded, 380–381

Consumer, implementing, 436–438

consumers, invoking from, 684–685

contains() method, 468, 486

contents, deleting, 173–174

context switch, 723

continue statement, 135–136

control flow statements, 102

controlling data with transactions bookmarking with savepoints, 894

committing and rolling back, 892–894

transaction APIs, 895

flow with branching about, 131

adding optional labels, 132

branching, 139

break statement, 133–135

continue statement, 135–136

nested loops, 131–132

return statement, 137–138

unreachable code, 138

life cycle of threads, 727

race conditions, 761

variable scope applying to classes, 47

limiting, 45–46

reviewing, 48

tracing, 46–47

converting List to arrays, 476–477

Coordinated Universal Time (UTC), 194

copy() method, 807–808

copying files, 806–808

core APIs about, 156, 208

arrays about, 178

comparing, 185–187

creating arrays of primitives, 179–180

creating arrays with reference variables, 180–182

multidimensional, 188–190

searching, 184–185

sorting, 183–184

using, 182–183

using methods with varargs, 187–188

dates and times about, 192–193

creating, 193–197

daylight saving time, 206–207

durations, 202–204

Instant class, 205

manipulating, 197–199

Period vs. Duration, 204–205

periods, 199–202

equality comparing equals() and ==, 175–176

string pool, 176–178

exam essentials, 209

math calculating exponents, 192

determining ceiling and floor, 191–192

finding minimum/maximum, 190–191

generating random numbers, 192

rounding numbers, 191

review question answers, 921–924

review questions, 210–218

StringBuilder class about, 170–171

chaining, 171

creating, 172

mutability, 171

StringBuilder methods, 172–175

strings about, 156

concatenating, 157–158

method chaining, 169–170

string methods, 158–169

count() method, 542

counting about, 542

elements of APIs, 467

covariant return types, 309–310

create() method, 568

createDirectory() method, 806

creating about, 172

abstract classes about, 315–317

creating concrete classes, 318–320

creating constructors in abstract classes, 320–321

declaring abstract methods, 317–318

finding invalid declarations, 321–323

arrays of primitives, 179–180

with reference variables, 180–182

.class files for inner classes, 384

classes accessing this reference, 283–284

applying class access modifiers, 282–283

calling super reference, 284–286

extending, 281–282

Comparable class, 492–496

concrete classes, 318–320

constructors about, 286–287

in abstract classes, 320–321

dates, 193–197

directories, 805–806

enums, 361–363

File class, 789–792

files, 665–666

finite streams, 539–540

generic classes, 504–506

generic records, 512

immutable objects declaring immutable classes, 323–325

performing defensive copies, 325–326

infinite streams, 540–541

JAR files, 20–21

Java runtimes, 696–697

List with constructors, 473–474

with factories, 472–473

local variables, 38–40

methods with varargs, 232–233

modular programs about, 664–665, 668–669

compiling modules, 666–668

creating files, 665–666

packaging modules, 669

nested classes about, 382, 401–402

declaring inner classes, 382–386

defining anonymous classes, 389–390

exam essentials, 402–403

review question answers, 932–936

review questions, 404–418

reviewing nested classes, 391

static, 386–387

writing local classes, 387–388

objects calling constructors, 22–23

executing instance initializer blocks, 23–24

following order of initialization, 24–25

reading member fields, 23

writing member fields, 23

Optional, 533–534

or loops about, 124

for-each loop, 129–130

for loops, 124–129

packages, 16

parallel streams, 539–540, 762

Path class, 789–792

random numbers, 192

resource bundles, 640–641

service locators, 682–684

services about, 680

adding service providers, 685–686

creating service locators, 682–684

declaring service provider interface, 681–682

invoking from consumers, 684–685

reviewing directives and services, 686–687

sources, 539–541

statements blocks, 102–103

else statement, 104–106

if statement, 103–104

pattern matching, 106–110

statements, 102–103

static nested classes, 386–387

strings about, 156

concatenating, 157–158

method chaining, 169–170

string methods, 158–169

threads, 724–725

threads with Concurrency API about, 730

increasing concurrency with pools, 739–740

scheduling tasks, 737–739

shutting down thread executors, 731–732

single-thread executor, 730–731

submitting tasks, 732–733

waiting for results, 733–736

times, 193–197

URLs, 870–871

wrapper classes, 31–32

custom text values, adding, 628–629

customizing date/time format, 626–629

records, 381–382

cyclic dependencies, 709–711

CyclicBarrier, orchestrating tasks with, 751–754

D

data controlling with transactions bookmarking with savepoints, 894

committing and rolling back, 892–894

transaction APIs, 895

encapsulating with records about, 401–402

applying records, 375–377

customizing records, 381–382

declaring constructors, 378–381

encapsulation, 374–375

exam essentials, 402–403

recording immutability, 377–378

review questions, 404–418

getting from ResultSet for columns, 885–886

reading ResultSet, 882–885

using bind variables, 887

inserting, 173

linking streams to underlying, 565–566

marking transient, 827

merging, 488–490

modifying, 875–876

passing among methods about, 253

autoboxing variables, 256–257

passing objects, 253–255

returning objects, 255

unboxing variables, 256–257

printing, 832–833

processing, 876–877

protecting with atomic classes, 742–744

reading, 876

serializing about, 824–825

applying Serializable interface, 825–826

deserialization creation process, 830–832

ensuring classes are Serializable, 827–828

marking data transient, 827

storing data with ObjectOutputStream and ObjectInputStream, 828–830

sorting about, 492

comparing Comparable and Comparator, 497–498

comparing data with Comparator, 496–497

comparing multiple fields, 498–500

creating Comparable class, 492–496

List, 503

searching and, 500–502

storing with ObjectOutputStream and ObjectInputStream, 828–830

types creating wrapper classes, 31–32

defining text blocks, 32–34

primitive, 27–28, 30

reference, 29–30

returning consistent, 118

underscore character, 29

writing literals, 28–29

databases closing resources, 895–897

connecting to building URL, 870–871

getting database Connection, 871–873

dates about, 192–193, 625–626

creating, 193–197

daylight saving time, 206–207

durations, 202–204

Instant class, 205

localizing, 637–638

manipulating, 197–199

Period vs. Duration, 204–205

periods, 199–202

daylight saving time, 206–207

deadlock, 758–760

debugging complicated generics, 577

decimal number system, 29

decision-making about, 102, 139–140

applying switch statements about, 110

switch expression, 115–121

switch statement, 110–115

controlling flow with branching about, 131

adding optional labels, 132

branching, 139

break statement, 133–135

continue statement, 135–136

nested loops, 131–132

return statement, 137–138

unreachable code, 138

creating for loops about, 124

for-each loop, 129–130

for loops, 124–129

creating statements blocks, 102–103

else statement, 104–106

if statement, 103–104

pattern matching, 106–110

statements, 102–103

exam essentials, 140–141

review question answers, 916–921

review questions, 142–154

writing while loops about, 121

do/while statement, 123

infinite loops, 123–124

while statement, 121–122

declarations finding invalid, 321–323

multiple arrays in, 180

declare rule, 594

declaring abstract methods, 317–318

concrete methods, 353–361

constructors about, 378–381

calling overload constructors with this(), 289–291

calling parent constructors with super(), 292–296

creating constructors, 286–287

default constructor, 287–289

exporting packages, 676–677

immutable classes, 323–325

inner classes, 382–386

instance variables about, 228–229

effectively final variables, 230–231

instance variable modifiers, 231–232

local variable modifiers, 229–230

interfaces, 345–348

local variables about, 228–229

effectively final variables, 230–231

instance variable modifiers, 231–232

local variable modifiers, 229–230

opening packages, 679–680

requiring transitively, 677–679

sealed classes, 367–368

service provider interface, 681–682

static interface methods, 357–358

subclasses, 276–278

variables identifying identifiers, 35–36

multiple, 36–38

decrement operator (–), 71–72

deep copy, 806

default constructor, 287–289

default methods, 223, 351–352, 354–357

default package, 16

defensive copies, performing, 325–326

defining anonymous classes, 389–390

instance and class variables, 41

text blocks, 32–34

delete() method, 173–174, 809

deleteCharAt() method, 173–174

deleteIfExists() method, 809

deleting contents, 173–174

depth-first search, 844

Deque interface about, 479–480

comparing implementations, 480

working with methods, 480–483

deserialization about, 825

creation process for, 830–832

designing. See also class design about, 220–221

access modifiers, 221–222

exception list, 227–228

method body, 228

method name, 226

method signature, 227

optional specifiers, 222–224

parameter list, 226–227

return types, 224–225

static methods and variables, 243–244

destroying objects about, 48

garbage collection, 48–49

tracing eligibility, 49–51

determining acceptable case values, 114–115

ceiling and floor, 191–192

equality of APIs, 470

exponents, 192

length, 158–159

order, 705–706

diamond operator (<>), 465–466

directives, 686–687

directories compiling to other, 18–19

creating, 805–806

referencing creating File or Path class, 789–792

file system, 786–789

searching, 847–848

directory trees, traversing, 843–847

disabling NullPointerException, 603

distinct() method, 549–550

dive() method, 428

division operators, 74–75

==, comparing with equals(), 175–176

:: operator, 429

double quotes (”“), 32

double type about, 114

functional interfaces for, 444–445

DoubleStream, 557–560

do/while statement, 123

downloading JDKs, 3

downstream collector, 575

DriverManager class, 871

duplicates, removing, 549–550

durations, 202–204

E

eat() method, 312

effectively final variables, 230–231

eligibility, tracing, 49–51

else statement, 90, 104–106

empty() method, 558

enabling NullPointerException, 603

encapsulating about, 374–375

data with records about, 401–402

applying records, 375–377

customizing records, 381–382

declaring constructors, 378–381

encapsulation, 374–375

exam essentials, 402–403

recording immutability, 377–378

review question answers, 932–936

review questions, 404–418

endsWith() method, 163

enums about, 361, 401–402

adding constructors, fields, and methods, 364–366

creating, 361–363

exam essentials, 402–403

review question answers, 932–936

review questions, 404–418

using in switch statements, 363–364

environment (Java) checking version of, 4

downloading JDKs, 3

major components, 2–3

equality checking for, 162

comparing equals() and ==, 175–176

operators for, 83–84

string pool, 176–178

equals() method, 162, 175–176, 280, 377, 381, 468, 470, 479, 495–496

equals operator (==), 83

equalsIgnoreCase() method, 162

equalsObject() method, 162

Error classes, 605

Error exceptions, 595

escapes, translating, 167

essential whitespace, 33

exam essentials class design, 327–329

collections and generics, 520

concurrency, 770–771

core APIs, 209

creating nested classes, 402–403

decision-making, 140–141

encapsulating data with records, 402–403

enums, 402–403

exceptions and localization, 647

implementing interfaces, 402–403

input/output (I/O), 851

Java, 52–53

Java Database Connectivity (JDBC), 898–899

lambdas and functional interfaces, 451–452

methods, 264

modules, 712

operators, 92–93

polymorphism, 402–403

sealing classes, 402–403

streams, 579–580

exception classes, recognizing checked Exception classes, 604–605

Error classes, 605

RuntimeException classes, 601–604

exception list, 227–228

exceptions and localization about, 592, 646

automating resource management about, 615

applying effectively final, 620–621

suppressed exceptions, 621–624

try-with-resources, 615–620

calling methods that throw [[exceptions, 598–599

checked exceptions, 307–308

exam essentials, 647

exception types, 593–596

formatting values customizing date/time format, 626–629

dates and times, 625–626

numbers, 624–625

handling exceptions adding finally blocks, 611–614

applying multi-catch blocks, 609–611

chaining catch blocks, 607–609

using try and catch statements, 606–607

loading properties with resource bundles about, 639–640

creating resource bundles, 640–641

formatting messages, 645

Properties class, 645–646

selecting resource bundles, 641–643

selecting values, 643–645

overriding methods with exceptions, 599

printing exceptions, 600

recognizing exception classes checked Exception classes, 604–605

Error classes, 605

RuntimeException classes, 601–604

review question answers, 945–948

review questions, 648–659

role of expectations, 592–593

supporting internationalization and localization about, 629–630

localizing dates, 637–638

localizing numbers, 632–637

picking locales, 630–632

specifying locale category, 638–639

throwing [[exceptions, 596–597

execute() method, 732–733, 876–877

executeBatch() methods, 881–882

executeQuery() method, 876

executeUpdate() method, 875–876

executing instance initializer blocks, 23–24

PreparedStatement, 875–878

ExecutorService, 730–733, 737–738

exitShell() method, 308

exponents, calculating, 192

exporting packages, 676–677

expressions, pattern variables and, 107–108

extending classes, 281–282

interfaces, 348–349

extends keyword, 348–349

F

factories, creating List with, 472–473

fall() method, 594, 607

fields about, 4–5

adding, 364–366

fifth() method, 519

File classes about, 84

creating, 789–792

operating on comparing files with isSameFile() and mismatch(), 809–811

copying files, 806–808

creating directories, 805–806

handling methods that declare IOException, 797

interacting with NIO.2 paths, 799–805

moving paths with move(), 808–809

providing NIO.2 optional parameters, 797–798

renaming paths with move(), 808–809

using shared functionality, 793–797

file systems, 786–789

files attributes of, 840–843

copying, 806–808

creating, 665–666

reading and writing combining with newBufferedReader() and newBufferedWriter(), 822–823

common read and write methods, 823–824

enhancing with Files, 820–822

using I/O streams, 817–820

referencing creating File or Path class, 789–792

file system, 786–789

Files.list() method, 843

FileSystem class, 791

filter() method, 549, 567

filtering, 549

final fields, initializing, 298–300

final keyword, 38–39, 223, 231, 278, 314, 369

finally blocks, adding, 611–614

find() method, 847

findAnswer() method, 40, 43

findAny() method, 543–544, 764

findFirst() method, 543–544

finding indexes, 159–160

invalid declarations, 321–323

minimum/maximum, 190–191, 542–543

values, 543–544

finite streams about, 536

creating, 539–540

first() method, 518

first-in, first-out (FIFO) method, 479–480, 482

flags, using format() with, 169

flatMap() method, 551, 561, 567

float type, 28, 114

floor determining, 191–192

value of, 75

floor() method, 191–192

flow controlling with branching about, 131

adding optional labels, 132

branching, 139

break statement, 133–135

continue statement, 135–136

nested loops, 131–132

return statement, 137–138

unreachable code, 138

scoping, 108–110

flush() method, 823–824

following order of initialization, 24–25

order of operations, 619–620

for loops about, 124–129

creating about, 124

for-each loop, 129–130

for loops, 124–129

for-each loop, 129–130

forEach() method, 469, 487, 545, 552–553

format() method, 168–169, 628, 835

formatted() method, 168–169

formatting messages, 645

values about, 167–169

customizing date/time format, 626–629

dates and times, 625–626

numbers, 624–625

fourth() method, 519

free store, 48

fully qualified class name, 15

Function, implementing, 439

functional interfaces. See also lambdas and functional interfaces built-in about, 434–435

checking functional interfaces, 441–442

functional interfaces for primitives, 443–445

implementing BiConsumer, 436–438

implementing BiFunction, 439

implementing BinaryOperator, 440–441

implementing BiPredicate, 438–439

implementing Consumer, 436–438

implementing Function, 439

implementing Predicate, 438–439

implementing Supplier, 435–436

implementing UnaryOperator, 440–441

using convenience methods on functional interfaces, 442–443

coding about, 426–427

adding object methods, 427–428

G

garbage collection, 48–49

generics. See collections and generics

get() method, 475, 487–488, 534, 683–684, 735–736

getAge() method, 321

getAsDouble() method, 563

getByte() method, 886

getChar() method, 886

getConnection() method, 872

getDelay() method, 737–738

getFilename() method, 801

getFloat() method, 886

getName() method, 320, 799, 800

getNameCount() method, 799, 800

getOrDefault() method, 487–488

getParent() method, 801

getPathSize() method, 845–846

getSize() method, 311, 845

getState() method, 727

getter. See accessor method

getting data from ResultSet for columns, 885–886

reading ResultSet, 882–885

using bind variables, 887

values, 487–488

getType() method, 350

Greenwich Mean Time (GMT), 194

grouping, 575–578

groupingBy() method, 575–578

H

handle rule, 594

hashCode() method, 162, 377, 381, 477–479, 484

HashMap class, 645

hasNext() method, 469

heap, 48

hexadecimal format, 29

hibernate() method, 313

hidden variables, 313

hide() method, 308

hiding members vs. overriding members, 399–401

static methods, 311–313

variables, 313–314

high-level streams, 814–815

HyperSQL database, 871–872

I

identifiers, identifying, 35–36

identifying built-in modules, 688–689

identifiers, 35–36

threading problems, 758–761

identity, 546

if statement, 90, 103–104

ifPresent() method, 534, 543, 566

IllegalArgumentException, 603–604

immutability

creating immutable objects

declaring immutable classes, 323–325

performing defensive copies, 325–326

declaring immutable classes, 323–325

recording, 377–378

immutable objects pattern, 323

implementing BiConsumer, 436–438

BiFunction, 439

BinaryOperator, 440–441

BiPredicate, 438–439

Consumer, 436–438

Function, 439

generic interfaces, 509–510

interfaces about, 345

declaring and using, 345–348

declaring concrete methods, 353–361

extending, 348–349

inheriting, 349–351

inserting implicit modifiers, 351–353

Map, 484

Predicate, 438–439

Queue and Dequeue, 480

Set, 477–478

Supplier, 435–436

UnaryOperator, 440–441

implicit modifiers, inserting, 351–353

import statement, 11, 13–14

imports and package declarations about, 11–12

compiling and running code with packages, 16–18

compiling to other directories, 18–19

compiling with JAR files, 20

creating JAR files, 20–21

creating packages, 16

naming conflicts, 15

ordering elements in classes, 21–22

packages, 12–13

redundant imports, 13–14

wildcards, 13

improving access with synchronized block]]s, 744–746

concurrency with pools, 739–740

IN parameters, passing, 889

incidental whitespace, 33

increment operator (++), 71–72

indent() method, 165–166

indentation braces ({}) and, 104

working with, 164–166

indexes, finding, 159–160

indexOf() method, 159–160

inferring type, with var, 41–44

infinite loops, 123–124

infinite streams about, 536

creating, 540–541

inheritance about, 276

class modifiers, 278

declaring subclasses, 276–278

duplicate abstract methods, 350–351

interfaces, 349–351

members about, 304–305

hiding static methods, 311–313

hiding variables, 313–314

overriding methods, 305–310

redeclaring private methods, 311

writing final methods, 314

Object, 279–280

single vs. multiple, 279

initializer, 547

initializing classes, 297–298

final fields, 298–300

instances, 300–304

objects initializing classes, 297–298

initializing final fields, 298–300

initializing instances, 300–304

variables creating local variables, 38–40

defining instance and class variables, 41

inferring type with var, 41–44

passing constructor and method parameters, 40

inner classes about, 382

creating .class files for, 384

declaring, 382–386

instantiating instances of, 384

referencing members of, 384–386

INOUT parameters, working with, 890–891

input streams, manipulating, 838–839

input/output (I/O) about, 786, 850

exam essentials, 851

interacting with users acquiring input with Console, 834–837

closing system streams, 833–834

printing data, 832–833

reading input as I/O streams, 833

key APIs, 848–850

operating on File and Path classes comparing files with isSameFile() and mismatch(), 809–811

copying files, 806–808

creating directories, 805–806

handling methods that declare IOException, 797

interacting with NIO.2 paths, 799–805

moving paths with move(), 808–809

providing NIO.2 optional parameters, 797–798

renaming paths with move(), 808–809

using shared functionality, 793–797

reading and writing files combining with newBufferedReader() and newBufferedWriter(), 822–823

common read and write methods, 823–824

enhancing with Files, 820–822

using I/O streams, 817–820

referencing files and directories creating File or Path class, 789–792

file system, 786–789

review question answers, 955–959

review questions, 852–862

serializing data about, 824–825

applying Serializable interface, 825–826

deserialization creation process, 830–832

ensuring classes are Serializable, 827–828

marking data transient, 827

storing data with ObjectOutputStream and ObjectInputStream, 828–830

streams about, 811–812

nomenclature, 812–817

reading input as, 833

using, 817–820

working with advanced APIs file attributes, 840–843

manipulating input streams, 838–839

searching directories, 847–848

traversing directory trees, 843–847

insert() method, 173

inserting data, 173

implicit modifiers, 351–353

Map through, 487

instance initializers, 25

instance methods calling on objects, 430–431

calling on parameters, 432

instance variables declaring about, 228–229

effectively final variables, 230–231

instance variable modifiers, 231–232

local variable modifiers, 229–230

defining, 41

modifiers for, 231–232

instanceof operator, 85–87, 397

instances, initializing, 300–304

Instant class, 205

instantiating instances of inner classes, 384

int type about, 28

functional interfaces for, 444–445

integrated development environment (IDE), 3

interacting with NIO.2 paths, 799–805

with users acquiring input with Console, 834–837

closing system streams, 833–834

printing data, 832–833

reading input as I/O streams, 833

interfaces. See also specific interfaces about, 401–402

casting, 396

compared with abstract classes, 352–353

generic, 509–510

implementing about, 345

declaring and using, 345–348

declaring concrete methods, 353–361

exam essentials, 402–403

extending, 348–349

inheriting, 349–351

inserting implicit modifiers, 351–353

review questions, 404–418

review question answers, 932–936

sealing, 372

intermediate operations, 549–553

internationalization and localization about, 629–630

localizing dates, 637–638

localizing numbers, 632–637

picking locales, 630–632

specifying locale category, 638–639

interrupt() method, 736

interrupting threads, 729–730

IntStream, 557–560

invoking, from consumers, 684–685

IOException, 595, 797

isBlank() method, 167

isDirectory() method, 840

isEmpty() method, 167, 432, 467

isPresent() method, 534

isRegularFile() method, 840

isSameFile() method, 809–811

isShutdown() method, 731

isSymbolicLink() method, 840

iterate() method, 540

iterating, 469, 545

J

jar, 693

JAR hell, 662

java, 690–692

Java about, 2, 51–52

class structure about, 4

comments, 5–7

fields and methods, 4–5

source files, 7

creating objects calling constructors, 22–23

executing instance initializer blocks, 23–24

following order of initialization, 24–25

reading member fields, 23

writing member fields, 23

creating runtimes, 696–697

data types creating wrapper classes, 31–32

defining text blocks, 32–34

primitive, 27–28, 30

reference, 29–30

underscore character, 29

writing literals, 28–29

declaring variables identifying identifiers, 35–36

multiple, 36–38

destroying objects about, 48

garbage collection, 48–49

tracing eligibility, 49–51

environment checking version of, 4

downloading JDKs, 3

major components, 2–3

exam essentials, 52–53

initializing variables creating local variables, 38–40

defining instance and class variables, 41

inferring type with var, 41–44

passing constructor and method parameters, 40

managing variable scope applying to classes, 47

limiting, 45–46

reviewing, 48

tracing, 46–47

operators about, 66

precedence, 67–69

types, 66–67

package declarations and imports about, 11–12

compiling and running code with packages, 16–18

compiling to other directories, 18–19

compiling with JAR files, 20

creating JAR files, 20–21

creating packages, 16

naming conflicts, 15

ordering elements in classes, 21–22

packages, 12–13

redundant imports, 13–14

wildcards, 13

passing parameters to Java programs, 9–11

review question answers, 910–913

review questions, 54–64

single-file source-code, 11

writing main() method, 8–11

Java archive (JAR) files about, 662

compiling with, 20

creating, 20–21

Java Database Connectivity (JDBC) about, 864, 897–898

calling CallableStatement about, 887–888

calling procedures without parameters, 888–889

comparing callable statement parameters, 891

passing IN parameters, 889

returning an OUT parameter, 889–890

using additional options, 891–892

working with INOUT parameters, 890–891

closing database resources, 895–897

connecting to databases building URL, 870–871

getting database Connection, 871–873

controlling data with transactions bookmarking with savepoints, 894

committing and rolling back, 892–894

transaction APIs, 895

exam essentials, 898–899

getting data from ResultSet for columns, 885–886

reading ResultSet, 882–885

using bind variables, 887

interfaces, 868–870

PreparedStatement about, 873–874

executing, 875–878

obtaining, 874–875

updating multiple records, 881–882

working with parameters, 878–880

relational databases and SQL about, 864–865

structure of relational databases, 866

writing basic SQL statements, 867–868

review question answers, 959–961

review questions, 900–908

Java Development Kit (JDK), 2–3

Java Persistence API (JPA), 865

Java Platform Module System (JPMS), 662–663

Java Runtime Environment (JRE), 3

Java Virtual Machine (JVM), 297, 600

Javadoc comment, 6

JavaPattern class, 106

jdeps, 693–695

jdk-internals flag, 695–696

jlink, 696–697

jmod, 696

K

keySet() method, 486, 641, 755

keywords. See also specific keywords about, 4

mixing class and interface, 350

L

labels, adding optional, 132

lambda bodies referencing variables from, 449–450

using local variables inside, 448–449

lambda expressions, anonymous classes and, 390

lambdas and functional interfaces about, 451

coding functional interfaces about, 426–427

adding object methods, 427–428

exam essentials, 451–452

review question answers, 936–939

review questions, 453–462

using method references about, 429–430, 433–434

calling constructors, 433

calling instance methods on objects, 430–431

calling instance methods on parameters, 432

calling static methods, 430

working with built-in functional interfaces about, 434–435

checking functional interfaces, 441–442

functional interfaces for primitives, 443–445

implementing BiConsumer, 436–438

implementing BiFunction, 439

implementing BinaryOperator, 440–441

implementing BiPredicate, 438–439

implementing Consumer, 436–438

implementing Function, 439

implementing Predicate, 438–439

implementing Supplier, 435–436

implementing UnaryOperator, 440–441

using convenience methods on functional interfaces, 442–443

working with variables in lambdas about, 445–446

listing parameters, 447–448

referencing variables from lambda bodies, 449–450

using local variables inside lambda bodies, 448–449

writing lambdas about, 420–422

syntax for lambdas, 422–425

last-in, first-out (LIFO), 482–483

laugh() method, 313

lazy evaluation, 537

length() method, 30, 158–159

limit() method, 550, 554, 555–556

limiting scope, 45–46

LinkedList, 472–474

linking streams, to underlying data, 565–566

Linux, 666

List interface about, 471

comparing implementations, 472

converting to arrays, 476–477

creating with constructors, 473–474

creating with factories, 472–473

working with methods, 474–476

list() method, 807

listing parameters, 447–448

literals, writing, 28–29

livelock, 760

liveness, 758–760

load() method, 682

loading classes, 297

properties with resource bundles about, 639–640

creating resource bundles, 640–641

formatting messages, 645

Properties class, 645–646

selecting resource bundles, 641–643

selecting values, 643–645

local classes about, 382

writing, 387–388

local variables creating, 38–40

declaring about, 228–229

effectively final variables, 230–231

instance variable modifiers, 231–232

local variable modifiers, 229–230

modifiers for, 229–230

using inside lambda bodies, 448–449

locales picking, 630–632

specifying category for, 638–639

localization. See exceptions and localization; internationalization and localization

localizing dates, 637–638

numbers, 632–637

Lock framework, 747–751

lock() method, 749–750

logging APIs, 833

logical complement operator (!), 70

logical operators, 87–88

long constructor, 378

long type, 28, 114, 444–445

LongStream, 557–560

low-level streams, 814–815

M

main() method, 243–244, 665, 724–725, 726, 731

managing dates, 197–199

exceptions adding finally blocks, 611–614

applying multi-catch blocks, 609–611

chaining catch blocks, 607–609

using try and catch statements, 606–607

input streams, 838–839

methods that declare IOException, 797

strings about, 156

concatenating, 157–158

method chaining, 169–170

string methods, 158–169

times, 197–199

MANIFEST.MF file, 701–702

Map interface about, 483–484

calling basic methods, 486

comparing implementations, 484

getting values, 487–488

inserting through, 487

merging data, 488–490

putIfAbsent() method, 488

replacing values, 488

working with methods, 484–485

map() method, 550

mapping about, 550, 575–578

streams, 560–563

mapToObj() method, 563

mark() method, 838–839

marking data transient, 827

matching, 544

math calculating exponents, 192

determining ceiling and floor, 191–192

finding minimum/maximum, 190–191

generating random numbers, 192

rounding numbers, 191

max() method, 32, 190–191, 542–543, 564–565

member fields, 23

member inner classes. See inner classes

members, inheriting about, 304–305

hiding static methods, 311–313

hiding variables, 313–314

overriding methods, 305–310

redeclaring private methods, 311

writing final methods, 314

memory consistency errors, 754–755

merge() method, 488–490

merging data, 488–490

messages, formatting, 645

method body, 228

method chaining, 169–170

method declaration, 220

method name, 226

method parameters, passing, 40

method references about, 429–430, 433–434

calling constructors, 433

instance methods on objects, 430–431

instance methods on parameters, 432

static methods, 430

method signatures, 5, 220, 227, 306–307

methods about, 4–5, 263–264

accessing static data accessing static variables or methods, 244–245

class vs. instance membership, 245–248

designing static methods and variables, 243–244

static imports, 251–252

static initializers, 250–251

static variable modifiers, 248–249

adding, 364–366

applying access modifiers about, 235

package access, 236–237

private access, 235–236

protected access, 237–241

public access, 242

reviewing access modifiers, 242–243

calling, that throw [[exceptions, 598–599

data among about, 253

autoboxing variables, 256–257

passing objects, 253–255

returning objects, 255

unboxing variables, 256–257

declaring local and instance variables about, 228–229

effectively final variables, 230–231

instance variable modifiers, 231–232

local variable modifiers, 229–230

Dequeue, 480–483

designing about, 220–221

access modifiers, 221–222

exception list, 227–228

method body, 228

method name, 226

method signature, 227

optional specifiers, 222–224

parameter list, 226–227

return types, 224–225

exam essentials, 264

generic, 510–511

List, 474–476

main(), 8–11

Map, 484–485

overloading about, 258–259, 262–263

arrays, 261

autoboxing, 261

primitives, 260–261

reference types, 259–260

varargs, 261–262

overriding, 162, 305–310, 397–399

overriding with exceptions, 599

passing data among about, 253

autoboxing variables, 256–257

passing objects, 253–255

returning objects, 255

unboxing variables, 256–257

Queue, 480–483

review question answers, 924–927

review questions, 265–274

Set, 478–479

varargs about, 187–188

accessing elements of, 234

calling methods with, 233

creating methods with, 232–233

using with other method parameters, 234

working with, 474–476

migrating applications about, 704–705

bottom-up migration strategy, 706–707

cyclic dependency, 709–711

determining order, 705–706

splitting big projects into modules, 709

top-down migration strategy, 707–708

min() method, 32, 190–191, 542–543, 564–565

minimum/maximum, finding, 190–191

mismatch() method, 185, 187, 809–811

mixing class and interface keywords, 350

modifiers class, 278

conflicting, 352

module declaration, 663

modules about, 662–664, 687, 711–712

benefits of, 664

command-line options, 697–700

compiling with, 870

creating and running modular programs about, 664–665, 668–669

compiling modules, 666–668

creating files, 665–666

packaging modules, 669

creating services about, 680

adding service providers, 685–686

creating service locators, 682–684

declaring service provider interface, 681–682

invoking from consumers, 684–685

reviewing directives and services, 686–687

declaration exporting packages, 676–677

opening packages, 679–680

requiring transitively, 677–679

exam essentials, 712

example of multiple, 669–675

identifying built-in, 688–689

jar, 693

java, 690–692

jdeps, 693–695

jdk-internals flag, 695–696

jlink, 696–697

jmod, 696

migrating applications about, 704–705

bottom-up migration strategy, 706–707

cyclic dependency, 709–711

determining order, 705–706

splitting big projects into modules, 709

top-down migration strategy, 707–708

review question answers, 949–951

review questions, 713–720

types about, 704

automatic, 701–703

named, 701

unnamed, 704

modulus operator (%), 74–75

move() method, 808–809

moving paths, with move(), 808–809

multi-catch blocks, applying, 609–611

multidimensional arrays, 188–190

multiple-line (multiline) comment, 6

multiplicative operators (*, /, %), 73

mutability, 171

mutable reduction, 547

mutator methods, 375

mutual exclusion, 744

N

name() method, calling, 362

named modules, 701

naming conflicts, 15

naming conventions, for generics, 504–505

native modifier, 223

negation operator (−), 70–71

nested classes about, 391

creating about, 401–402

review questions, 404–418

exam essentials, 402–403

nested loops, 131–132

nested subclasses, referencing, 371

newBufferedReader(), combining with, 822–823

newBufferedWriter(), combining with, 822–823

newSingleThreadExecutor() method, 731

next() method, 469

NIO.2 paths, interacting with, 799–805

nomenclature, for streams, 812–817

noneMatch() method, 544

nonsealed modifier, 278, 368, 370

normalize() method, 803–804

NoSQL database, 865

now() method, 194

null variable, 87, 470, 494–495, 536

NullPointerException, 89, 602–603

NumberFormatException, 604

numbers about, 624–625

localizing, 632–637

rounding, 191

numeric comparison operators, 85–87

numeric promotion, 75–77, 256

O

Object, inheriting, 279–280

object methods, adding, 427–428

ObjectInputStream, storing data with, 828–830

ObjectOutputStream, storing data with, 828–830

objects about, 4

casting, 395–396

compared with references, 49

creating calling constructors, 22–23

executing instance initializer blocks, 23–24

following order of initialization, 24–25

reading member fields, 23

writing member fields, 23

destroying about, 48

garbage collection, 48–49

tracing eligibility, 49–51

initializing initializing classes, 297–298

initializing final fields, 298–300

initializing instances, 300–304

passing, 253–255

vs. reference, 393–394

returning, 255

obtaining input with Console, 834–837

PreparedStatement, 874–875

synchronized collections, 757–758

octal format, 29

of() method, 201, 559

open source software, 662

opening packages, 679–680

operators about, 92

arithmetic about, 72–73

adding parentheses, 73–74

division, 74–75

modulus, 74–75

assigning values assignment operator, 77

casting values, 77–81

compound assignment operators, 81–82

return value of assignment operators, 82–83

comparing values conditional operators, 88–90

equality operators, 83–84

logical operators, 87–88

relational operators, 84–87

exam essentials, 92–93

on File and Path classes comparing files with isSameFile() and mismatch(), 809–811

copying files, 806–808

creating directories, 805–806

handling methods that declare IOException, 797

interacting with NIO.2 paths, 799–805

moving paths with move(), 808–809

providing NIO.2 optional parameters, 797–798

renaming paths with move(), 808–809

using shared functionality, 793–797

Java about, 66

precedence, 67–69

types, 66–67

numeric promotion, 75–77

review question answers, 913–916

review questions, 94–100

ternary, 90–92

unary about, 69

complement, 69–70

decrement, 70–71

increment, 70–71

negation, 69–70

Optional creating, 533–534

empty, 534–536

returning about, 532

creating Optional, 533–534

dealing with empty Optional, 534–536

using, 563–564

optional modifiers, in main() methods, 9

optional specifiers, 222–224

order of initialization, following, 24–25

order of operations about, 67–69

changing, 73–74

following, 619–620

ordering elements in classes, 21–22

ordinal() method, 362

orElseGet() method, 563

OUT parameter, returning, 889–890

overflow, 79

overloaded constructors about, 380–381

calling with this(), 289–291

overloading generic methods, 507–508

methods about, 258–259, 262–263

arrays, 261

autoboxing, 261

primitives, 260–261

reference types, 259–260

varargs, 261–262

overriding members vs. hiding members, 399–401

methods, 162, 305–310, 397–399

methods with exceptions, 599

P

package access, 221, 235, 236–237

package declarations and imports about, 11–12

compiling and running code with packages, 16–18

compiling to other directories, 18–19

compiling with JAR files, 20

creating JAR files, 20–21

creating packages, 16

naming conflicts, 15

ordering elements in classes, 21–22

packages, 12–13

redundant imports, 13–14

wildcards, 13

packages about, 12–13

compiling and running code with, 16–18

creating, 16

exporting, 676–677

of modules, 669

opening, 679–680

parallel decomposition, performing, 762–764

parallel reductions, processing, 764–769

parallel streams about, 761–762

creating, 539–540, 762

performing parallel decomposition, 762–764

processing parallel reductions, 764–769

parameter list, 226–227

parameters about, 5

calling procedures without, 888–889

comparing callable statement, 891

listing, 447–448

passing to Java programs, 9–11

transforming, 379–380

working with, 878–880

parent constructors, calling with super(), 292–296

parentheses adding, 73–74

verifying syntax, 74

parse() method, 632, 634–635

partitioning, 575–578

PartitioningBy() method, 575–578

pass-by-reference, 254–255

pass-by-value, 254–255

passing constructor parameters, 40

data among methods about, 253

autoboxing variables, 256–257

passing objects, 253–255

returning objects, 255

unboxing variables, 256–257

method parameters, 40

objects, 253–255

IN parameters, 889

parameters to Java programs, 9–11

path, 787

Path classes creating, 789–792

operating on comparing files with isSameFile() and mismatch(), 809–811

copying files, 806–808

creating directories, 805–806

handling methods that declare IOException, 797

interacting with NIO.2 paths, 799–805

moving paths with move(), 808–809

providing NIO.2 optional parameters, 797–798

renaming paths with move(), 808–809

using shared functionality, 793–797

pattern matching, 106–110

pattern variables about, 107

expressions and, 107–108

peek() method, 552–553

performing defensive copies, 325–326

parallel decomposition, 762–764

tasks with CyclicBarrier, 751–754

period (.), 20

Period, Duration compared with, 204–205

periods, 199–202

permits clause, 368, 370–372

pipeline flow, 536–539, 553–556

Plain Old Java Object (POJO), 374

play() method, 352–353, 508

pointer, 29–30

polling, 727–729

polymorphism about, 392–393, 401–402

casting objects, 395–396

exam essentials, 402–403

instanceof operator, 397

method overriding, 397–399

object vs. reference, 393–394

overriding vs. hiding members, 399–401

review question answers, 932–936

review questions, 404–418

pools, increasing concurrency with, 739–740

position, restricting by, 550

pow() method, 192

Practical Database Programming with Java (Bai), 864

precedence of operators, 67–69

Predicate, implementing, 438–439

prepareCall() method, 889

PreparedStatement about, 873–874

executing, 875–878

obtaining, 874–875

updating multiple records, 881–882

working with parameters, 878–880

preview features, 3

primary key, 866

primitive assignments, 78–79

primitive data type, 27–28, 30

primitive streams about, 557–560

mapping streams, 560–563

summarizing statistics, 564–565

using Optional with, 563–564

primitives creating arrays of, 179–180

functional interfaces for, 443–445

primitives methods, 260–261

printData() method, 286

printing data, 832–833

elements in reverse, 126–127

exceptions, 600

stream references, 540

printList() method, 514

println() statement, 26

private access, 235–236

private methods about, 354

redeclaring, 311

reusing code with, 358–359

private modifier, 221, 235

processing data, 876–877

parallel reductions, 764–769

properties, loading with resource bundles about, 639–640

creating resource bundles, 640–641

formatting messages, 645

Properties class, 645–646

selecting resource bundles, 641–643

selecting values, 643–645

Properties class, 645–646

protected access, 237–241

protected modifier, 222, 235

public access, 242

public modifier, 4–5, 222, 235, 354

put() method, 486

putIfAbsent() method, 488

Q

Queue interface about, 479–480

comparing implementations, 480

working with methods, 480–483

R

race conditions defined, 741

managing, 761

random() method, 192

random numbers, generating, 192

range() method, 560

raw type, 509

read accessor methods, 325

read() method, 817–820, 838–839

reading data, 876

files combining with newBufferedReader() and newBufferedWriter(), 822–823

common read and write methods, 823–824

enhancing with Files, 820–822

using I/O streams, 817–820

input as I/O streams, 833

member fields, 23

ResultSet, 882–885

readLine() method, 833

readObject() method, 829

reassigning pattern variables, 107

recording immutability, 377–378

records applying, 375–377

customizing, 381–382

encapsulating data with about, 401–402

applying records, 375–377

customizing records, 381–382

declaring constructors, 378–381

encapsulation, 374–375

exam essentials, 402–403

recording immutability, 377–378

review questions, 404–418

generic, 512

serializing, 828

redeclaring private methods, 311

reduce() method, 545–547, 765–767

reducing, 545–547

reductions, 541

redundant imports, 13–14

ReentrantLock class, applying, 747–748

reference data type, 29–30, 259–260

reference variables, creating arrays with, 180–182

references about, 4

compared with objects, 49

vs. objects, 393–394

referencing files and directories

creating File or Path class, 789–792

file system, 786–789

members of inner classes, 384–386

nested subclasses, 371

variables from lambda bodies, 449–450

reflection, 679

relational databases, SQL and about, 864–865

structure of relational databases, 866

writing basic SQL statements, 867–868

relational operators, 84–87

relativize() method, 802–803

remainder operator, 74–75

remove() method, 466–467, 476

removeIf() method, 468–469

removing with conditions, 468–469

data from APIs, 466–467

duplicates, 549–550

whitespace, 163–164

renaming paths with move(), 808–809

replace() method, 163, 174

replaceAll() method, 475

replacing portions, 174

values, 163, 488

requires statement, 678–679

reserved type name, 44

reset() method, 838–839

resolution, module, 692

resolve() method, 802

resource bundles creating, 640–641

loading properties with about, 639–640

creating resource bundles, 640–641

formatting messages, 645

Properties class, 645–646

selecting resource bundles, 641–643

selecting values, 643–645

selecting, 641–643

resource management, automating applying effectively final, 620–621

suppressed exceptions, 621–624

try-with-resources, 615–620

restricting, by position, 550

results, collecting, 570–578

ResultSet for columns, 885–886

reading ResultSet, 882–885

using bind variables, 887

return statement, 137–138

return types about, 9, 224–225

covariant, 309–310

return value, of assignment operators, 82–83

returning consistent data types, 118

generic types, 508

objects, 255

Optional about, 532

creating Optional, 533–534

dealing with empty Optional, 534–536

OUT parameter, 889–890

reusing code with private interface methods, 358–359

reverse() method, 174–175

reverseOrder() method, 552

reversing, 174–175

review question answers class design, 927–932

collections and generics, 939–942

concurrency, 951–955

core APIs, 921–924

creating nested classes, 932–936

decision-making, 916–921

encapsulating data with records, 932–936

enums, 932–936

exceptions and localization, 945–948

input/output (I.O), 955–959

interfaces, 932–936

Java, 910–913

JDBC, 959–961

lambdas and functional interfaces, 936–939

methods, 924–927

modules, 949–951

operators, 913–916

polymorphism, 932–936

sealing classes, 932–936

streams, 942–945

review questions class design, 330–344

collections and generics, 521–529

concurrency, 772–783

creating nested classes, 404–418

decision-making, 142–154

encapsulating data with records, 404–418

enums, 404–418

exceptions and localization, 648–659

implementing interfaces, 404–418

input/output (I/O), 852–862

Java, 54–64

Java Database Connectivity (JDBC), 900–908

lambdas and functional interfaces, 453–462

methods, 265–274

modules, 713–720

operators, 94–100

polymorphism, 404–418

sealing classes, 404–418

streams, 581–590

roar() method, 282

root directory, 787

round() method, 191, 430

rounding numbers, 191

round-robin schedule, 723

running code with packages, 16–18

modular programs about, 664–665, 668–669

compiling modules, 666–668

creating files, 665–666

packaging modules, 669

runtime exception, 595

RuntimeException classes, 601–604

S

schedule() method, 737–738

scheduleAtFixedRate() method, 738

scheduleWithFixedDelay() method, 739

scheduling tasks, 737–739

scope, of try-with-resources, 619

sealed modifier, 278, 367, 369–370

sealing classes about, 367, 401–402

compiling, 368–369

declaring, 367–368

exam essentials, 402–403

omitting permits clause, 370–372

review question answers, 932–936

review questions, 404–418

rules for, 372–373

sealing interfaces, 372

specifying subclass modifier, 369–370

search depth, 844

searching arrays, 184–185

directories, 847–848

for substrings, 163

second() method, 518–519

selecting format() method, 628

locales, 630–632

resource bundles, 641–643

switch data types, 114

values, 643–645

semicolons, in switch expressions, 119–120

Serializable interface, applying, 825–826

serializing about, 825

data about, 824–825

applying Serializable interface, 825–826

deserialization creation process, 830–832

ensuring classes are Serializable, 827–828

marking data transient, 827

storing data with ObjectOutputStream and ObjectInputStream, 828–830

service locators, creating, 682–684

service providers adding, 685–686

declaring interface, 681–682

ServiceLoader, 683–684

services about, 686–687

creating about, 680

adding service providers, 685–686

creating service locators, 682–684

declaring service provider interface, 681–682

invoking from consumers, 684–685

reviewing directives and services, 686–687

Set interface about, 477

comparing implementations, 477–478

working with methods, 478–479

setAge() method, 282

setDefault() method, 632

setName() method, 5

setProperties() method, 282

setter. See mutator methods

shallow copy, 806

shared environment, 722

shared functionality, 793–797

ship() method, 509–510

short type, 28

short-circuit operators. See conditional operators

shortening code, 106–110

shutdown() method, 731–732, 736

shutting down thread executors, 731–732

single abstract method (SAM) rule, 426

single inheritance, compared with multiple inheritance, 279

single-file source-code, 11

single-line comment, 5–6

single-thread executor, 730–731

size() method, 467

skip() method, 222, 550, 839

sleep() method, 308, 508, 729

snake-case, 132

sneeze() method, 313

sort() method, 501, 503

sorted() method, 552, 555

sorting about, 552

arrays, 183–184

data about, 492

comparing Comparable and Comparator, 497–498

comparing data with Comparator, 496–497

comparing multiple fields, 498–500

creating Comparable class, 492–496

List, 503

searching and, 500–502

source files, 7

sources, creating, 539–541

specifying locale category, 638–639

subclass modifier, 369–370

Spliterator, 569–570

splitting big projects, into modules, 709

sprint() method, 427

SQL For Dummies, 9th Edition (Taylor), 864

startsWith() method, 163, 431

starvation, 760

stateful lambda expression, 769

statements. See also specific statements about, 102–103

batching, 881–882

creating blocks, 102–103

else statement, 104–106

if statement, 103–104

pattern matching, 106–110

statements, 102–103

defined, 11

static data, accessing accessing static variables or methods, 244–245

class vs. instance membership, 245–248

designing static methods and variables, 243–244

static imports, 251–252

static initializers, 250–251

static variable modifiers, 248–249

static imports, 251–252

static initializers, 250–251

static interface methods, 357–358

static methods about, 351–352

calling, 430

hiding, 311–313

static modifier, 47, 223, 278

static nested classes about, 382

creating, 386–387

static variable modifiers, 248–249

statistics, summarizing, 564–565

stored procedures, 887

storing data, with ObjectOutputStream and ObjectInputStream, 828–830

stream() method, 555

streams about, 532, 578–579, 811–812

advanced stream pipeline concepts chaining Optionals, 566–568

collecting results, 570–578

linking streams to underlying data, 565–566

using Spliterator, 569–570

concatenating, 551

exam essentials, 579–580

nomenclature, 812–817

primitive about, 557–560

mapping streams, 560–563

summarizing statistics, 564–565

using Optional with, 563–564

returning Optional about, 532

creating Optional, 533–534

dealing with empty Optional, 534–536

review question answers, 942–945

review questions, 581–590

using creating sources, 539–541

pipeline flow, 536–539, 553–556

using common intermediate operations, 549–553

using common terminal operations, 541–549

strictfp modifier, 223

string methods, 158–169

string pool, 176–178

StringBuilder class about, 170–171

chaining, 171

creating, 172

mutability, 171

StringBuilder methods, 172–175

StringBuilder methods, 172–175

strings, creating and manipulating about, 156

concatenating, 157–158

method chaining, 169–170

string methods, 158–169

strip() method, 163–164

stripIndent() method, 165–166

stripLeading() method, 164

stripTrailing() method, 164

Structured Query Language (SQL), 865

subclasses declaring, 276–278

specifying modifiers, 369–370

submit() method, 732–733, 735, 736

submitting tasks, 732–733

subname, 870

subpath() method, 800

subprotocol, 870

substring() method, 160–161

substrings about, 160–161

searching for, 163

subtypes, 108

sum, 32

summarizing statistics, 564–565

super() method, calling parent constructors with, 292–296

super reference, calling, 284–286

supplier, 548

Supplier, implementing, 435–436

suppressed exceptions, 621–624

swap() method, 254–255

switch expression, 115–121

switch statements about, 110–115

applying about, 110

switch expression, 115–121

switch statement, 110–115

using enums in, 363–364

synchronized block]]s, improving access with, 744–746

synchronized collections, obtaining, 757–758

synchronized modifier]], 223

synchronizing, on methods, 746–747

system streams, closing, 833–834

System.exit() method, 614

T

tasks scheduling, 737–739

submitting, 732–733

Taylor, Allen G. (author) SQL For Dummies, 9th Edition, 864

teeing() method, 577

terminal operations, 541–549

ternary operators, 90–92

text blocks, defining, 32–34

third() method, 519

this() method, calling overload constructors with, 289–291

this reference, accessing, 283–284

thread executors, shutting down, 731–732

thread priority, 723

thread scheduler, 723

threads about, 722–723

creating, 724–725

creating with Concurrency API about, 730

increasing concurrency with pools, 739–740

scheduling tasks, 737–739

shutting down thread executors, 731–732

single-thread executor, 730–731

submitting tasks, 732–733

waiting for results, 733–736

interrupting, 729–730

managing life cycle of, 727

polling, 727–729

types, 725–726

writing thread-safe code about, 740–741

accessing data with volatile, 741–742

improving access with synchronized block]]s, 744–746

Lock framework, 747–751

orchestrating tasks with CyclicBarrier, 751–754

protecting data with atomic classes, 742–744

synchronizing on methods, 746–747

Throwable exception, 595

throwing [[exceptions, 596–597

times about, 192–193, 625–626

creating, 193–197

daylight saving time, 206–207

durations, 202–204

Instant class, 205

manipulating, 197–199

Period vs. Duration, 204–205

periods, 199–202

top-down migration strategy, 707–708

top-level type, 7

toRealPath() method, 804

toString() method, 162, 175, 280, 377, 381, 428, 436, 799, 894

toUpperCase() method, 161

tracing eligibility, 49–51

scope, 46–47

transaction APIs, 895

transforming parameters, 379–380

transient modifier, 231

translateEscapes() method, 167

translating escapes, 167

traversing directory trees, 843–847

trim() method, 163–164

try and catch statements, 606–607

tryAdvance() method, 570

tryLock() method, 749–750

try-with-resources, 615–620

type erasure, 506–508

erase, erasing

U

unary operators about, 69

complement, 69–70

decrement, 70–71

increment, 70–71

negation, 69–70

UnaryOperator, implementing, 440–441

unboxing variables, 256–257

un[[checked exceptions, 595

underflow, 79

underscore (_) character, 29, 36

unnamed modules, 704

unperformed side effect, 90–92

unreachable code, 138

updating multiple records, 881–882

URLs, building, 870–871

user-defined thread, 726

users, interacting with acquiring input with Console, 834–837

closing system streams, 833–834

printing data, 832–833

reading input as I/O streams, 833

V

valueOf() method, 31, 363

values appending, 172–173

assigning assignment operator, 77

casting values, 77–81

compound assignment operators, 81–82

return value of assignment operators, 82–83

casting, 77–81

comparing conditional operators, 88–90

equality operators, 83–84

logical operators, 87–88

relational operators, 84–87

finding, 543–544

formatting about, 167–169

customizing date/time format, 626–629

dates and times, 625–626

numbers, 624–625

getting, 487–488

replacing, 163, 488

selecting, 643–645

values() method, 362, 487

var assigning lambdas to, 425

inferring type with, 41–44

using with ArrayList, 474

varargs about, 261–262

accessing elements of, 234

calling methods with, 233

creating methods with, 232–233

using methods with, 187–188

using with other method parameters, 234

variables autoboxing, 256–257

casting, 80–81

declaring identifying identifiers, 35–36

multiple, 36–38

hiding, 313–314

initializing creating local variables, 38–40

defining instance variable and class variables, 41

inferring type with var, 41–44

passing constructor parameter and method parameters, 40

managing scope applying to classes, 47

limiting, 45–46

reviewing, 48

tracing, 46–47

referencing from lambda bodies, 449–450

unboxing, 256–257

working with in lambdas about, 445–446

listing parameters, 447–448

referencing variables from lambda bodies, 449–450

using local variables inside lambda bodies, 448–449

versions, checking for Java, 4

void keyword, 5

volatile modifier about, 231

accessing data with, 741–742

W

walk() method, 844–845, 845–846, 848

whatAmI() method, 447

while loops about, 728–729

writing about, 121

do/while statement, 123

infinite loops, 123–124

while statement, 121–122

while statement, 121–122

whitespace, removing, 163–164

wildcards about, 13

compiling with, 17

generic types, 512

wrapper classes, creating, 31–32

write() method, 817–820

writeObject() method, 829

writing basic SQL statements, 867–868

default methods, 354–357

files combining with newBufferedReader() and newBufferedWriter(), 822–823

common read and write methods, 823–824

enhancing with Files, 820–822

using I/O streams, 817–820

final methods, 314

generic methods, 510–511

lambdas, 420–422 syntax for lambdas, 422–425

literals, 28–29

local classes, 387–388

main() method, 8–11

member fields, 23

thread-safe code about, 740–741

accessing data with volatile, 741–742

improving access with synchronized block]]s, 744–746

Lock framework, 747–751

orchestrating tasks with CyclicBarrier, 751–754

protecting data with atomic classes, 742–744

synchronizing on methods, 746–747

while loops about, 121

do/while statement, 123

infinite loops, 123–124

while statement, 121–122

Y

Fair Use Sources

Java: Java Fundamentals, Java Inventor - Java Language Designer: James Gosling of Sun Microsystems, Java Docs, JDK, JVM, JRE, Java Keywords, JDK 17 API Specification, java.base, Java Built-In Data Types, Java Data Structures - Java Algorithms, Java Syntax, Java OOP - Java Design Patterns, Java Installation, Java Containerization, Java Configuration, Java Compiler, Java Transpiler, Java IDEs (IntelliJ - Eclipse - NetBeans), Java Development Tools, Java Linter, JetBrains, Java Testing (JUnit, Hamcrest, Mockito), Java on Android, Java on Windows, Java on macOS, Java on Linux, Java DevOps - Java SRE, Java Data Science - Java DataOps, Java Machine Learning, Java Deep Learning, Functional Java, Java Concurrency, Java History,

Java Bibliography (Effective Java, Head First Java, Java - A Beginner's Guide by Herbert Schildt, Java Concurrency in Practice, Clean Code by Robert C. Martin, Java - The Complete Reference by Herbert Schildt, Java Performance by Scott Oaks, Thinking in Java, Java - How to Program by Paul Deitel, Modern Java in Action, Java Generics and Collections by Maurice Naftalin, Spring in Action, Java Network Programming by Elliotte Rusty Harold, Functional Programming in Java by Pierre-Yves Saumont, Well-Grounded Java Developer, Second Edition, Java Module System by Nicolai Parlog

), Manning Java Series, Java Glossary, Java Topics, Java Courses, Java Security - Java DevSecOps, Java Standard Library, Java Libraries, Java Frameworks, Java Research, Java GitHub, Written in Java, Java Popularity, Java Awesome List, Java Versions. (navbar_java and navbar_java_detailed - see also navbar_jvm, navbar_java_concurrency, navbar_java_standard_library, navbar_java_libraries, navbar_java_navbars)


Cloud Monk is Retired (for now). Buddha with you. © 2005 - 2024 Losang Jinpa or Fair Use. Disclaimers

SYI LU SENG E MU CHYWE YE. NAN. WEI LA YE. WEI LA YE. SA WA HE.


ocp_oracle_certified_professional_java_se_17_developer_study_guide_index.txt · Last modified: 2022/08/30 04:25 by 127.0.0.1