AP* Computer Science Review Companion for Fundamentals of Java |
|
iii | |
Preface |
|
v | |
|
UNIT 1 Getting Started with Java |
|
|
|
|
3 | (28) |
|
|
3 | (2) |
|
Computer Hardware and Software |
|
|
5 | (5) |
|
Binary Representation of Information and Computer Memory |
|
|
10 | (9) |
|
|
19 | (1) |
|
The Software Development Process |
|
|
20 | (3) |
|
Basic Concepts of Object-Oriented Programming |
|
|
23 | (8) |
|
|
28 | (3) |
|
|
31 | (26) |
|
|
31 | (1) |
|
The Java Virtual Machine and Byte Code |
|
|
32 | (1) |
|
Choosing a User Interface Style |
|
|
33 | (1) |
|
|
34 | (3) |
|
Edit, Compile, and Execute |
|
|
37 | (5) |
|
|
42 | (4) |
|
Graphics and GUIs: Windows and Panels |
|
|
46 | (11) |
|
|
52 | (5) |
|
Syntax, Errors, and Debugging |
|
|
57 | (48) |
|
|
57 | (2) |
|
Basic Java Syntax and Semantics |
|
|
59 | (15) |
|
Terminal I/O for Different Data Types |
|
|
74 | (3) |
|
|
77 | (5) |
|
|
82 | (5) |
|
|
87 | (5) |
|
Graphics and GUIs: Drawing Shapes and Text |
|
|
92 | (13) |
|
|
100 | (5) |
|
Introduction to Control Statements |
|
|
105 | (50) |
|
|
105 | (2) |
|
Standard Classes and Methods |
|
|
107 | (2) |
|
|
109 | (2) |
|
The if and if-else Statements |
|
|
111 | (5) |
|
|
116 | (4) |
|
|
120 | (4) |
|
Nested Control Statements and the break Statement |
|
|
124 | (3) |
|
Using Loops with Text Files |
|
|
127 | (6) |
|
|
133 | (4) |
|
Graphics and GUIs: I/O Dialog Boxes and Loops |
|
|
137 | (18) |
|
Design, Testing, and Debugging Hints |
|
|
143 | (1) |
|
|
144 | (5) |
|
|
149 | (6) |
|
UNIT 2 The Next Step with Java |
|
|
|
Introduction to Defining Classes |
|
|
155 | (44) |
|
The Internal Structure of Classes and Objects |
|
|
155 | (2) |
|
|
157 | (11) |
|
Editing, Compiling, and Testing the Student Class |
|
|
168 | (6) |
|
The Structure and Behavior of Methods |
|
|
174 | (3) |
|
Scope and Lifetime of Variables |
|
|
177 | (6) |
|
Graphics and GUIs: Images, a Circle Class, and Mouse Events |
|
|
183 | (16) |
|
|
194 | (5) |
|
Control Statements Continued |
|
|
199 | (48) |
|
|
199 | (13) |
|
|
212 | (3) |
|
|
215 | (3) |
|
Logical Errors in Nested if Statements |
|
|
218 | (4) |
|
|
222 | (2) |
|
|
224 | (4) |
|
|
228 | (6) |
|
Graphics and GUIs: Timers and Animations |
|
|
234 | (13) |
|
Design, Testing, and Debugging Hints |
|
|
241 | (1) |
|
|
242 | (5) |
|
Improving the User Interface |
|
|
247 | (22) |
|
|
247 | (1) |
|
|
248 | (1) |
|
A Menu-Driven Conversion Program |
|
|
249 | (3) |
|
Formatted Output with printf and format |
|
|
252 | (5) |
|
Handling Number Format Exceptions during Input |
|
|
257 | (1) |
|
|
258 | (11) |
|
|
265 | (4) |
|
Introduction to HTML and Applets |
|
|
269 | (36) |
|
Hypertext, Hypermedia, and the World Wide Web |
|
|
269 | (2) |
|
Overview of the Hypertext Markup Language |
|
|
271 | (4) |
|
|
275 | (2) |
|
Character-Level Formatting |
|
|
277 | (1) |
|
|
278 | (3) |
|
Linking to Other Documents |
|
|
281 | (2) |
|
|
283 | (3) |
|
|
286 | (2) |
|
|
288 | (17) |
|
|
295 | (4) |
|
|
299 | (6) |
|
UNIT 3 Arrays, Recursion, and Complexity |
|
|
|
|
305 | (46) |
|
|
306 | (1) |
|
Simple Array Manipulations |
|
|
307 | (2) |
|
|
309 | (2) |
|
|
311 | (3) |
|
Working with Arrays That Are Not Full |
|
|
314 | (3) |
|
|
317 | (1) |
|
|
318 | (3) |
|
Using the Enhanced for Loop |
|
|
321 | (2) |
|
|
323 | (3) |
|
|
326 | (12) |
|
Graphics and GUIs: Changing the View of Student Test Scores |
|
|
338 | (13) |
|
Design, Testing, and Debugging Hints |
|
|
343 | (1) |
|
|
343 | (8) |
|
|
351 | (54) |
|
Class (static) Variables and Methods |
|
|
352 | (4) |
|
|
356 | (3) |
|
Java Interfaces---The Client Perspective |
|
|
359 | (3) |
|
Java Interfaces---The Implementation Perspective |
|
|
362 | (5) |
|
Code Reuse Through Inheritance |
|
|
367 | (5) |
|
Inheritance and Abstract Classes |
|
|
372 | (5) |
|
Some Observations about Interfaces, Inheritance, and Relationships among Classes |
|
|
377 | (3) |
|
Acceptable Classes for Parameters and Return Values |
|
|
380 | (3) |
|
Error Handling with Classes |
|
|
383 | (2) |
|
|
385 | (7) |
|
Reference Types, Equality, and Object Identity |
|
|
392 | (3) |
|
Graphics and GUIs: Drawing Multiple Shapes |
|
|
395 | (10) |
|
|
402 | (3) |
|
|
405 | (50) |
|
Advanced Operations on Strings |
|
|
405 | (6) |
|
|
411 | (4) |
|
|
415 | (7) |
|
|
422 | (4) |
|
Working with Arrays of Objects |
|
|
426 | (3) |
|
The Class java.util.ArrayList |
|
|
429 | (13) |
|
|
442 | (13) |
|
|
450 | (5) |
|
Recursion, Complexity, and Searching and Sorting |
|
|
455 | (52) |
|
|
456 | (12) |
|
|
468 | (7) |
|
|
475 | (3) |
|
|
478 | (4) |
|
|
482 | (7) |
|
Graphics and GUIs: Drawing Recursive Patterns |
|
|
489 | (18) |
|
Design, Testing, and Debugging Hints |
|
|
497 | (1) |
|
|
497 | (4) |
|
|
501 | (6) |
|
UNIT 4 Using Abstract Data Types |
|
|
|
Object-Oriented Analysis and Design |
|
|
507 | (50) |
|
|
508 | (1) |
|
Overview of Analysis and Design |
|
|
509 | (1) |
|
|
510 | (1) |
|
|
511 | (11) |
|
Interlude: Support Classes for Menu-Driven Programs |
|
|
522 | (6) |
|
|
528 | (8) |
|
|
536 | (8) |
|
Graphics and GUIs: Text Areas, Scrolling List Boxes, and a GUI-Based Adventure Game |
|
|
544 | (13) |
|
|
553 | (4) |
|
Linear Collections: Lists |
|
|
557 | (26) |
|
|
558 | (4) |
|
|
562 | (10) |
|
|
572 | (11) |
|
|
578 | (5) |
|
Linear Collections: Stacks and Queues |
|
|
583 | (42) |
|
|
583 | (13) |
|
The StringTokenizer Class |
|
|
596 | (5) |
|
Queues and Priority Queues |
|
|
601 | (16) |
|
Graphics and GUIs: Check Boxes and Radio Buttons |
|
|
617 | (8) |
|
|
620 | (5) |
|
Unordered Collections: Sets and Maps |
|
|
625 | (34) |
|
|
626 | (3) |
|
|
629 | (3) |
|
Example Application: Word Frequencies |
|
|
632 | (2) |
|
|
634 | (4) |
|
|
638 | (6) |
|
The Glue that Holds Collections Together |
|
|
644 | (15) |
|
|
649 | (4) |
|
|
653 | (6) |
|
UNIT 5 Implementing Abstract Data Types |
|
|
|
|
659 | (36) |
|
Interfaces, Multiple Implementations, and Prototypes |
|
|
659 | (2) |
|
The IndexedList Interface |
|
|
661 | (2) |
|
The Fixed-Size Array Implementation of Indexed Lists |
|
|
663 | (1) |
|
The Singly Linked Implementation of Indexed Lists |
|
|
664 | (10) |
|
Complexity Analysis of Indexed List Implementations |
|
|
674 | (3) |
|
|
677 | (5) |
|
Fixed-Size Array Implementation of Positional Lists |
|
|
682 | (3) |
|
Doubly Linked Implementation of Positional Lists |
|
|
685 | (5) |
|
Complexity Analysis of Positional Lists |
|
|
690 | (1) |
|
|
691 | (4) |
|
|
691 | (4) |
|
Implementing Sets and Maps |
|
|
695 | (20) |
|
The Set and Map Prototypes |
|
|
696 | (2) |
|
List Implementations of Sets and Maps |
|
|
698 | (1) |
|
|
699 | (5) |
|
Hashing Implementation of Maps |
|
|
704 | (5) |
|
Hashing Implementation of Sets |
|
|
709 | (6) |
|
|
712 | (3) |
|
Implementing Trees and Priority Queues |
|
|
715 | |
|
|
715 | (9) |
|
|
724 | (3) |
|
A Linked Implementation of Binary Trees |
|
|
727 | (10) |
|
An Array Implementation of Binary Trees |
|
|
737 | (3) |
|
|
740 | (3) |
|
Using a Heap to Implement a Priority Queue |
|
|
743 | |
|
|
744 | (5) |
|
|
749 | |
Appendix A Java Resources |
|
1 | (1) |
Appendix B Java Language Elements |
|
1 | (1) |
Appendix C Operator Precedence |
|
1 | (1) |
Appendix D ASCII Character Set |
|
1 | (1) |
Appendix E Number Systems |
|
1 | (1) |
Appendix F Java Exception Handling |
|
1 | (1) |
Appendix G Java Packages and jar Files |
|
1 | (1) |
Appendix H Files |
|
1 | (1) |
Appendix I The TurtleGraphics Package |
|
1 | (1) |
Appendix J AP Correlations |
|
1 | (1) |
Glossary |
|
1 | (1) |
Index |
|
1 | |