Introduction |
|
xxi | |
The Assessment Test |
|
xliii | |
|
Chapter 1 Welcome to Java |
|
|
1 | (34) |
|
Learning About the Java Environment |
|
|
2 | (2) |
|
|
2 | (1) |
|
|
3 | (1) |
|
Identifying Benefits of Java |
|
|
4 | (1) |
|
Understanding the Java Class Structure |
|
|
5 | (3) |
|
|
5 | (1) |
|
|
6 | (2) |
|
|
8 | (1) |
|
|
8 | (5) |
|
|
9 | (1) |
|
Passing Parameters to a Java Program |
|
|
10 | (2) |
|
Running a Program in One Line |
|
|
12 | (1) |
|
Understanding Package Declarations and Imports |
|
|
13 | (11) |
|
|
15 | (1) |
|
|
15 | (1) |
|
|
16 | (2) |
|
|
18 | (1) |
|
Compiling and Running Code with Packages |
|
|
19 | (1) |
|
Using an Alternate Directory |
|
|
20 | (2) |
|
|
22 | (1) |
|
|
23 | (1) |
|
Running a Program in One Line with Packages |
|
|
24 | (1) |
|
Ordering Elements in a Class |
|
|
24 | (2) |
|
Code Formatting on the Exam |
|
|
26 | (1) |
|
|
27 | (1) |
|
|
27 | (2) |
|
|
29 | (6) |
|
Chapter 2 Java Building Blocks |
|
|
35 | (44) |
|
|
36 | (4) |
|
|
36 | (1) |
|
Reading and Writing Member Fields |
|
|
37 | (1) |
|
Executing Instance Initializer Blocks |
|
|
38 | (1) |
|
Following Order of Initialization |
|
|
39 | (1) |
|
|
40 | (6) |
|
|
40 | (4) |
|
|
44 | (1) |
|
Distinguishing between Primitives and Reference Types |
|
|
45 | (1) |
|
|
46 | (4) |
|
|
46 | (3) |
|
Declaring Multiple Variables |
|
|
49 | (1) |
|
|
50 | (9) |
|
|
51 | (1) |
|
Passing Constructor and Method Parameters |
|
|
52 | (1) |
|
Defining Instance and Class Variables |
|
|
53 | (1) |
|
|
53 | (6) |
|
|
59 | (3) |
|
|
59 | (1) |
|
|
60 | (1) |
|
|
60 | (1) |
|
Applying Scope to Classes |
|
|
61 | (1) |
|
|
62 | (1) |
|
|
62 | (5) |
|
Understanding Garbage Collection |
|
|
63 | (1) |
|
|
64 | (3) |
|
|
67 | (1) |
|
|
67 | (2) |
|
|
69 | (10) |
|
|
79 | (34) |
|
Understanding Java Operators |
|
|
80 | (2) |
|
|
80 | (1) |
|
|
81 | (1) |
|
|
82 | (3) |
|
Logical Complement and Negation Operators |
|
|
83 | (1) |
|
Increment and Decrement Operators |
|
|
84 | (1) |
|
Working with Binary Arithmetic Operators |
|
|
85 | (5) |
|
|
86 | (2) |
|
|
88 | (2) |
|
|
90 | (5) |
|
|
90 | (1) |
|
|
90 | (3) |
|
Compound Assignment Operators |
|
|
93 | (1) |
|
Assignment Operator Return Value |
|
|
94 | (1) |
|
|
95 | (7) |
|
|
95 | (2) |
|
|
97 | (2) |
|
|
99 | (1) |
|
|
100 | (2) |
|
Making Decisions with the Ternary Operator |
|
|
102 | (1) |
|
|
103 | (1) |
|
|
104 | (1) |
|
|
105 | (8) |
|
Chapter 4 Making Decisions |
|
|
113 | (48) |
|
Creating Decision-Making Statements |
|
|
114 | (12) |
|
|
114 | (1) |
|
|
115 | (1) |
|
|
116 | (3) |
|
|
119 | (7) |
|
|
126 | (4) |
|
|
126 | (1) |
|
|
127 | (1) |
|
Comparing while and do/while Loops |
|
|
128 | (1) |
|
|
129 | (1) |
|
|
130 | (11) |
|
|
131 | (5) |
|
|
136 | (5) |
|
Controlling Flow with Branching |
|
|
141 | (8) |
|
|
141 | (1) |
|
|
142 | (1) |
|
|
143 | (2) |
|
|
145 | (2) |
|
|
147 | (1) |
|
|
148 | (1) |
|
|
148 | (1) |
|
|
149 | (1) |
|
|
150 | (1) |
|
|
151 | (10) |
|
|
161 | (60) |
|
Creating and Manipulating Strings |
|
|
162 | (10) |
|
|
163 | (1) |
|
|
164 | (1) |
|
|
165 | (6) |
|
|
171 | (1) |
|
Using the StringBuilder Class |
|
|
172 | (5) |
|
|
173 | (1) |
|
|
174 | (1) |
|
Important StringBuilder Methods |
|
|
174 | (3) |
|
|
177 | (3) |
|
Comparing equals() and == |
|
|
177 | (2) |
|
|
179 | (1) |
|
Understanding Java Arrays |
|
|
180 | (13) |
|
Creating an Array of Primitives |
|
|
181 | (2) |
|
Creating an Array with Reference Variables |
|
|
183 | (2) |
|
|
185 | (1) |
|
|
186 | (1) |
|
|
187 | (1) |
|
|
188 | (2) |
|
|
190 | (1) |
|
|
190 | (3) |
|
Understanding an ArrayList |
|
|
193 | (11) |
|
|
193 | (2) |
|
|
195 | (4) |
|
|
199 | (2) |
|
|
201 | (1) |
|
Converting Between array and List |
|
|
201 | (2) |
|
Using Varargs to Create a List |
|
|
203 | (1) |
|
|
204 | (1) |
|
|
204 | (2) |
|
|
204 | (1) |
|
|
205 | (1) |
|
Calculating with Math APIs |
|
|
206 | (2) |
|
|
206 | (1) |
|
|
207 | (1) |
|
|
207 | (1) |
|
|
208 | (1) |
|
|
208 | (1) |
|
|
209 | (1) |
|
|
210 | (11) |
|
Chapter 6 Lambdas and Functional Interfaces |
|
|
221 | (26) |
|
|
222 | (5) |
|
|
222 | (3) |
|
|
225 | (2) |
|
Introducing Functional Interfaces |
|
|
227 | (4) |
|
|
228 | (1) |
|
|
228 | (1) |
|
|
229 | (1) |
|
|
230 | (1) |
|
Working with Variables in Lambdas |
|
|
231 | (3) |
|
|
231 | (1) |
|
Local Variables inside the Lambda Body |
|
|
231 | (1) |
|
Variables Referenced from the Lambda Body |
|
|
232 | (2) |
|
Calling APIs with Lambdas |
|
|
234 | (2) |
|
|
234 | (1) |
|
|
235 | (1) |
|
|
235 | (1) |
|
|
236 | (1) |
|
|
237 | (1) |
|
|
238 | (9) |
|
Chapter 7 Methods and Encapsulation |
|
|
247 | (48) |
|
|
248 | (6) |
|
|
249 | (1) |
|
|
250 | (1) |
|
|
251 | (1) |
|
|
252 | (1) |
|
|
253 | (1) |
|
|
253 | (1) |
|
|
254 | (1) |
|
|
254 | (2) |
|
Applying Access Modifiers |
|
|
256 | (8) |
|
|
256 | (1) |
|
Default (Package-Private) Access |
|
|
257 | (2) |
|
|
259 | (4) |
|
|
263 | (1) |
|
Applying the static Keyword |
|
|
264 | (8) |
|
Designing static Methods and Fields |
|
|
264 | (1) |
|
Accessing a static Variable or Method |
|
|
265 | (1) |
|
|
266 | (2) |
|
|
268 | (1) |
|
|
269 | (1) |
|
|
270 | (2) |
|
Passing Data among Methods |
|
|
272 | (3) |
|
|
275 | (6) |
|
|
277 | (1) |
|
|
277 | (1) |
|
|
277 | (2) |
|
|
279 | (1) |
|
|
279 | (1) |
|
|
280 | (1) |
|
|
280 | (1) |
|
|
281 | (2) |
|
|
283 | (1) |
|
|
284 | (1) |
|
|
285 | (10) |
|
|
295 | (68) |
|
Understanding Inheritance |
|
|
296 | (3) |
|
Single vs. Multiple Inheritance |
|
|
297 | (1) |
|
|
298 | (1) |
|
|
299 | (6) |
|
|
299 | (2) |
|
Applying Class Access Modifiers |
|
|
301 | (1) |
|
Accessing the this Reference |
|
|
302 | (1) |
|
Calling the super Reference |
|
|
303 | (2) |
|
|
305 | (18) |
|
|
305 | (1) |
|
|
306 | (2) |
|
Calling Overloaded Constructors with this() |
|
|
308 | (2) |
|
Calling Parent Constructors with super() |
|
|
310 | (4) |
|
Constructors and final Fields |
|
|
314 | (2) |
|
|
316 | (6) |
|
Reviewing Constructor Rules |
|
|
322 | (1) |
|
|
323 | (14) |
|
Calling Inherited Members |
|
|
323 | (1) |
|
|
324 | (12) |
|
|
336 | (1) |
|
Understanding Polymorphism |
|
|
337 | (9) |
|
|
339 | (1) |
|
|
340 | (1) |
|
|
341 | (1) |
|
Polymorphism and Method Overriding |
|
|
342 | (2) |
|
Overriding vs. Hiding Members |
|
|
344 | (2) |
|
|
346 | (1) |
|
|
347 | (2) |
|
|
349 | (14) |
|
Chapter 9 Advanced Class Design |
|
|
363 | (38) |
|
Creating Abstract Classes |
|
|
364 | (9) |
|
Introducing Abstract Classes |
|
|
364 | (2) |
|
Defining Abstract Methods |
|
|
366 | (4) |
|
Creating a Concrete Class |
|
|
370 | (2) |
|
Reviewing Abstract Class Rules |
|
|
372 | (1) |
|
|
373 | (15) |
|
|
373 | (4) |
|
Inserting Implicit Modifiers |
|
|
377 | (3) |
|
|
380 | (4) |
|
Polymorphism and Interfaces |
|
|
384 | (2) |
|
Reviewing Interface Rules |
|
|
386 | (2) |
|
Introducing Inner Classes |
|
|
388 | (2) |
|
Defining a Member Inner Class |
|
|
388 | (1) |
|
Using a Member Inner Class |
|
|
389 | (1) |
|
|
390 | (1) |
|
|
391 | (1) |
|
|
392 | (9) |
|
|
401 | (50) |
|
|
402 | (7) |
|
|
402 | (2) |
|
Understanding Exception Types |
|
|
404 | (3) |
|
|
407 | (2) |
|
Recognizing Exception Classes |
|
|
409 | (5) |
|
|
409 | (3) |
|
Checked Exception Classes |
|
|
412 | (1) |
|
|
413 | (1) |
|
|
414 | (18) |
|
Using try and catch Statements |
|
|
414 | (2) |
|
|
416 | (2) |
|
Applying a Multi-catch Block |
|
|
418 | (3) |
|
|
421 | (3) |
|
Finally Closing Resources |
|
|
424 | (6) |
|
Throwing Additional Exceptions |
|
|
430 | (2) |
|
Calling Methods That Throw Exceptions |
|
|
432 | (5) |
|
Declaring and Overriding Methods with Exceptions |
|
|
434 | (1) |
|
|
435 | (2) |
|
|
437 | (1) |
|
|
438 | (2) |
|
|
440 | (11) |
|
|
451 | (40) |
|
|
452 | (4) |
|
|
453 | (1) |
|
|
454 | (2) |
|
Creating and Running a Modular Program |
|
|
456 | (7) |
|
|
457 | (1) |
|
Compiling Our First Module |
|
|
458 | (2) |
|
|
460 | (1) |
|
Packaging Our First Module |
|
|
461 | (2) |
|
Updating Our Example for Multiple Modules |
|
|
463 | (7) |
|
Updating the Feeding Module |
|
|
463 | (1) |
|
|
464 | (2) |
|
Creating the Talks Module |
|
|
466 | (3) |
|
Creating the Staff Module |
|
|
469 | (1) |
|
Diving into the module-info File |
|
|
470 | (5) |
|
|
470 | (2) |
|
|
472 | (2) |
|
provides, uses, and opens |
|
|
474 | (1) |
|
|
475 | (6) |
|
|
475 | (3) |
|
|
478 | (1) |
|
|
478 | (2) |
|
|
480 | (1) |
|
Reviewing Command-Line Options |
|
|
481 | (2) |
|
|
483 | (1) |
|
|
484 | (1) |
|
|
485 | (6) |
|
Appendix Answers to Review Questions |
|
|
491 | (38) |
|
Chapter 1 Welcome to Java |
|
|
492 | (2) |
|
Chapter 2 Java Building Blocks |
|
|
494 | (4) |
|
|
498 | (3) |
|
Chapter 4 Making Decisions |
|
|
501 | (4) |
|
|
505 | (4) |
|
Chapter 6 Lambdas and Functional Interfaces |
|
|
509 | (2) |
|
Chapter 7 Methods and Encapsulation |
|
|
511 | (2) |
|
|
513 | (5) |
|
Chapter 9 Advanced Class Design |
|
|
518 | (4) |
|
|
522 | (4) |
|
|
526 | (3) |
Index |
|
529 | |