Objects First with Java: A Practical Introduction Using BlueJ

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

This book is an introduction to object-oriented programming for beginners. The main focus of the book is general object-oriented and programming concepts from a software engineering perspective.

Author(s): David J. Barnes & Michael Kölling
Series: Objects First with Java: A Practical Introduction Using BlueJ 6th Edition
Edition: 6th
Publisher: Pearson
Year: 2016

Language: English
Pages: 667
Tags: java, bluej, oop

Cover......Page 1
Title Page......Page 2
Copyright Page......Page 3
Contents......Page 6
Foreword......Page 15
Preface......Page 16
List of Projects Discussed in Detail in This Book......Page 26
Acknowledgments......Page 29
Part 1 Foundations of Object Orientation
......Page 30
1.1 Objects and classes......Page 32
1.2 Creating objects......Page 33
1.3 Calling methods......Page 34
1.4 Parameters......Page 35
1.5 Data types......Page 36
1.6 Multiple instances......Page 37
1.7 State......Page 38
1.8 What is in an object?......Page 39
1.9 Java code......Page 40
1.10 Object interaction......Page 41
1.11 Source code......Page 42
1.13 Return values......Page 44
1.14 Objects as parameters......Page 45
1.15 Summary......Page 46
2.1 Ticket machines......Page 50
2.2 Examining a class definition......Page 52
2.3 The class header......Page 54
2.4 Fields, constructors, and methods......Page 55
2.5 Parameters: receiving data......Page 61
2.6 Assignment......Page 63
2.7 Methods......Page 64
2.8 Accessor and mutator methods......Page 65
2.9 Printing from methods......Page 68
2.11 Summary of the naíve ticket machine......Page 71
2.12 Reflecting on the design of the ticket machine......Page 72
2.13 Making choices: the conditional statement......Page 74
2.14 A further conditional-statement example......Page 76
2.15 Scope highlighting......Page 77
2.16 Local variables......Page 78
2.17 Fields, parameters, and local variables......Page 80
2.19 Self-review exercises......Page 82
2.20 Reviewing a familiar example......Page 84
2.21 Calling methods......Page 86
2.22 Experimenting with expressions: the Code Pad......Page 88
2.23 Summary......Page 90
3.1 The clock example......Page 96
3.2 Abstraction and modularization......Page 97
3.4 Modularization in the clock example......Page 98
3.5 Implementing the clock display......Page 99
3.6 Class diagrams versus object diagrams......Page 100
3.8 The NumberDisplay class......Page 101
3.9 The ClockDisplay class......Page 109
3.10 Objects creating objects......Page 112
3.12 Method calls......Page 113
3.13 Another example of object interaction......Page 117
3.14 Using a debugger......Page 121
3.15 Method calling revisited......Page 125
3.16 Summary......Page 126
4.1 Building on themes from Chapter 3......Page 130
4.2 The collection abstraction......Page 131
4.3 An organizer for music files......Page 132
4.4 Using a library class......Page 133
4.5 Object structures with collections......Page 136
4.6 Generic classes......Page 138
4.7 Numbering within collections......Page 139
4.8 Playing the music files......Page 142
4.9 Processing a whole collection......Page 144
4.10 Indefinite iteration......Page 149
4.11 Improving structure—the Track class......Page 157
4.12 The Iterator type......Page 160
4.13 Summary of the music-organizer project......Page 164
4.14 Another example: an auction system......Page 166
4.15 Summary......Page 176
5.1 An alternative look at themes from Chapter 4......Page 178
5.2 Monitoring animal populations......Page 179
5.3 A first look at lambdas......Page 183
5.4 The forEach method of collections......Page 185
5.5 Streams......Page 187
5.6 Summary......Page 197
Chapter 6 More-Sophisticated Behavior......Page 200
6.1 Documentation for library classes......Page 201
6.2 The TechSupport system......Page 202
6.3 Reading class documentation......Page 207
6.4 Adding random behavior......Page 212
6.5 Packages and import......Page 218
6.6 Using maps for associations......Page 219
6.8 Dividing strings......Page 224
6.9 Finishing the TechSupport system......Page 226
6.10 Autoboxing and wrapper classes......Page 228
6.11 Writing class documentation......Page 230
6.12 Public versus private......Page 233
6.13 Learning about classes from their interfaces......Page 235
6.14 Class variables and constants......Page 240
6.15 Class methods......Page 243
6.17 Further advanced material......Page 245
6.18 Summary......Page 249
7.1 Fixed-size collections......Page 252
7.3 A log-file analyzer......Page 253
7.4 The for loop......Page 259
7.5 The automaton project......Page 265
7.6 Arrays of more than one dimension (advanced)......Page 273
7.7 Arrays and streams (advanced)......Page 280
7.8 Summary......Page 281
Chapter 8 Designing Classes......Page 284
8.1 Introduction......Page 285
8.2 The world-of-zuul game example......Page 286
8.3 Introduction to coupling and cohesion......Page 288
8.4 Code duplication......Page 289
8.5 Making extensions......Page 292
8.6 Coupling......Page 295
8.7 Responsibility-driven design......Page 299
8.8 Localizing change......Page 302
8.9 Implicit coupling......Page 303
8.10 Thinking ahead......Page 306
8.11 Cohesion......Page 307
8.12 Refactoring......Page 311
8.13 Refactoring for language independence......Page 315
8.14 Design guidelines......Page 320
8.15 Summary......Page 321
9.1 Introduction......Page 324
9.2 Testing and debugging......Page 325
9.3 Unit testing within BlueJ......Page 326
9.4 Test automation......Page 333
9.5 Refactoring to use streams (advanced)......Page 340
9.6 Debugging......Page 341
9.7 Commenting and style......Page 343
9.8 Manual walkthroughs......Page 344
9.9 Print statements......Page 349
9.10 Debuggers......Page 353
9.11 Debugging streams (advanced)......Page 354
9.12 Choosing a debugging strategy......Page 355
9.14 Summary......Page 356
Part 2 Application Structures......Page 358
10.1 The network example......Page 360
10.2 Using inheritance......Page 372
10.3 Inheritance hierarchies......Page 374
10.4 Inheritance in Java......Page 375
10.5 Network: adding other post types......Page 378
10.6 Advantages of inheritance (so far)......Page 380
10.7 Subtyping......Page 381
10.8 The Object class......Page 387
10.9 The collection hierarchy......Page 388
10.10 Summary......Page 389
11.1 The problem: network’s display method......Page 392
11.2 Static type and dynamic type......Page 394
11.3 Overriding......Page 397
11.4 Dynamic method lookup......Page 399
11.5 super call in methods......Page 402
11.7 Object methods: toString......Page 403
11.8 Object equality: equals and hashCode......Page 406
11.9 Protected access......Page 408
11.10 The instanceof operator......Page 410
11.11 Another example of inheritance with overriding......Page 411
11.12 Summary......Page 414
12.1 Simulations......Page 418
12.2 The foxes-and-rabbits simulation......Page 419
12.3 Abstract classes......Page 434
12.4 More abstract methods......Page 441
12.5 Multiple inheritance......Page 443
12.6 Interfaces......Page 446
12.7 A further example of interfaces......Page 454
12.9 Abstract class or interface?......Page 456
12.10 Event-driven simulations......Page 457
12.11 Summary of inheritance......Page 458
12.12 Summary......Page 459
13.1 Introduction......Page 462
13.2 Components, layout, and event handling......Page 463
13.4 The ImageViewer example......Page 464
13.5 ImageViewer 1.0: the first complete version......Page 476
13.6 ImageViewer 2.0: improving program structure......Page 490
13.7 ImageViewer 3.0: more interface components......Page 496
13.8 Inner classes......Page 500
13.9 Further extensions......Page 505
13.10 Another example: MusicPlayer......Page 507
13.11 Summary......Page 510
Chapter 14 Handling Errors......Page 512
14.1 The address-book project......Page 513
14.2 Defensive programming......Page 517
14.3 Server error reporting......Page 520
14.4 Exception-throwing principles......Page 524
14.5 Exception handling......Page 530
14.6 Defining new exception classes......Page 537
14.7 Using assertions......Page 539
14.8 Error recovery and avoidance......Page 542
14.9 File-based input/output......Page 545
14.10 Summary......Page 556
15.1 Analysis and design......Page 558
15.2 Class design......Page 565
15.3 Documentation......Page 567
15.5 Prototyping......Page 568
15.6 Software growth......Page 569
15.7 Using design patterns......Page 571
15.8 Summary......Page 577
16.1 The case study......Page 580
16.2 Analysis and design......Page 581
16.3 Class design......Page 585
16.4 Iterative development......Page 590
16.6 Taking things further......Page 599
A.4 Configuring BlueJ......Page 600
A.7 Changing the new class templates......Page 601
B.1 Primitive types......Page 602
B.3 Object types......Page 603
B.5 Casting of object types......Page 604
C.1 Arithmetic expressions......Page 606
C.2 Boolean expressions......Page 607
C.3 Short-circuit operators......Page 608
D.2 Selection statements......Page 610
D.3 Loops......Page 612
D.4 Exceptions......Page 614
D.5 Assertions......Page 616
E.1 Executing without BlueJ......Page 618
E.3 Developing without BlueJ......Page 620
Appendix F: Using the Debugger......Page 622
F.2 The control buttons......Page 623
F.3 The variable displays......Page 624
F.5 The Threads display......Page 625
G.3 Creating a test method......Page 626
G.6 Fixtures......Page 627
H.4 Using a shared project......Page 628
H.6 More information......Page 629
I.1 Documentation comments......Page 630
I.2 BlueJ support for javadoc......Page 632
J.2 Layout......Page 634
J.3 Documentation......Page 635
J.4 Language-use restrictions......Page 636
J.5 Code idioms......Page 637
K.1 The java.lang package......Page 638
K.2 The java.util package......Page 639
K.3 The java.io and java.nio.file packages......Page 640
K.5 The java.net package......Page 641
K.6 Other important packages......Page 642
Appendix L: Concept Glossary......Page 644
A......Page 650
B......Page 651
C......Page 652
D......Page 654
E......Page 655
G......Page 656
I......Page 657
J......Page 658
L......Page 659
M......Page 660
O......Page 661
P......Page 662
S......Page 663
T......Page 665
W......Page 666