Object-Oriented Programming with Java
Barry J. Holmes, Daniel T. Joyce
Résumé
Contents
Introduction 1 What is Java? 2 Using the Internet 3 Downloading the Java 2 SDK for Windows, 4 Unix (Solaris), and Linux Users Downloading Java 2 SDK Documentation 4 Creating a Java Software Development 5 Environment Copying and Installing the Audio-Visual 7 Interface How to Input and Save a Java Program in the 9 Computer How to Compile a Java Program 10 How to Execute (run) a Java Program 12 SDK Tools 14 Copying and Editing Programs from the CD 15 Summary 17 Primitive Data Types and Arithmetic 19 Data 20 Data Storage 21 Number Systems 23 Identifiers 27 Syntax 29 Variables and Constants 31 The Format of a Simple Program 33 Arithmetic 35 Unary Operators 35 Binary Multiplicative Operators 35 Binary Additive Operators 35 Operator Precedence 40 Casting 42 Summary 45 Review Questions 46 Exercises 47 Programming Problems 49 Objects 51 Introduction to Objects 52 The String Class 53 Declaring Objects 54 Methods and Parameters 54 Constructors 56 String Assignment 58 Instance Methods 58 The Anatomy of a Simple Program Revisted 61 Heading Giving Details of the Name and 62 Purpose of the Program Import List 62 Class Name 63 Main Method 63 The AVI Package 63 The Window Class 65 Input to a Dialog Box 69 Converting Strings to Numbers 72 Command Line Arguments 75 Errors 78 Syntax Errors 78 Run-Time Errors 82 Logical Errors 82 Summary 82 Review Questions 83 Exercises 84 Programming Problems 85 Object-Oriented Programming 87 Abstract Data Type 88 Constructors 90 Instance Methods 93 Class Methods 101 Scope and Lifetime of Identifiers 104 Software Development 106 Object-Oriented Program Design 108 Identify the Classes and Methods 109 Algorithm Development 111 Testing 112 Compilation and Execution 112 Documentation 113 Case Study: Cutting Logs 116 The AVI Package Revisited 124 The Audio Class 125 The Timer Class 128 The Filmstrip Class 130 Case Study: A Simulation of Rolling a Die 135 Summary 144 Review Questions 146 Exercises 147 Programming Problems 150 Selection 153 More AVI Classes 154 The Slider Class 154 The RadioButtons Class 156 If..else Statement 161 Nested If Statement 166 Conditional Expressions 172 Else if Statements 176 Boolean Data Type 177 Switch 179 Wrapper Classes 184 Case Study: Body Mass Index 185 Yet another AVI Class! 194 The Memo Class 194 The This Object 195 Case Study: Validation of Dates including 196 Leap Years Summary 209 Review Questions 210 Exercises 210 Programming Problems 212 Repetition and One-Dimensional Arrays 217 Loop Structure 218 While Loop 220 While Loop Controlled by a Counter 220 While Loop Controlled by Data 220 Do..while Loop 227 Increment/Decrement Operators 232 For Loop 235 Which Loop? 239 while 240 do..while 240 for 240 Arrays Revisited 241 Declaring and Initializing One-Dimensional 242 Arrays Three Methods 242 Using Arrays 245 Case Study: Palindrome 253 Our Last AVI Class: CheckBoxes 261 The CheckBox Class 261 Formatting Numbers for Output 264 Case Study: Ben's Breakfast Bar 267 Summary 282 Review Questions 283 Exercises 283 Programming Problems 285 Advanced Concepts with Classes 289 Inheritance 290 An Example of Inheritance 292 Overriding Superclass Methods 299 Polymorphism 303 Instanceof Operator 307 Shadowed Variables 309 Inner Classes 312 Abstract Methods and Classes 312 Case Study: Boats 317 Interfaces 339 Constructors Revisited 345 Instance Methods Revisited 347 Object Properties 348 Comparing Objects 348 Copying Objects 350 Passing Objects as Parameters 352 Case Study: Arithmetic of Rational Numbers 353 Garbage Collection and Object Finalization 361 Summary 363 Review Questions 365 Exercises 366 Programming Problems 371 Exceptions and Streams 375 Introduction 376 Exception Classes 377 Catching an Exception 379 Catching Multiple Exceptions 383 Creating Your Own Exception Class 387 Throwing an Exception 390 Finally Blocks 394 Using Exception Handling 396 Stream Input and Output 398 The Stream Tokenizer Class 404 Text File Processing 407 Book Example Problem 412 Another Example: Using a File Viewer 417 The FileDialog Class 419 Case Study: Reporting on the Statistics 422 of a Text File Summary 433 Review Questions 434 Exercises 435 Programming Problems 438 An Introduction to the java.awt Package 443 Creating a Container 444 Handling an Event 448 Adding a Button to the Container 451 Adding Labels, Fonts, and Text Fields to a 457 Container Labels 457 Fonts 458 Text Fields 461 Adding Check Boxes, Radio Buttons, and 465 Lists to a Container Check Boxes 465 Radio Buttons 468 List 472 Creating a Reusable Container 476 Creating a Reusable WritingPad Component 480 Creating a Reusable DialogBox Component 486 Creating a Reusable CheckBoxes Component 491 Java Swing 497 Summary 497 Review Questions 499 Exercises 500 Programming Problems 500 Vectors, Serialization, and the java.awt 501 Graphics Class Vectors 502 Case Study: Chemical Elements 508 Saving and Loading Serializable Objects 520 The Graphics Class 524 Mouse Events 527 Pop-Up Menus 534 Painting the Screen 544 Printing Objects 548 Summary 558 Review Questions 558 Exercises 559 Programming Problems 560 Objects Working Together 563 Packages 564 Associations 570 CRC Cards 582 Aggregation 586 Composition 598 Building a Student Management System 599 Menus Revisited 604 Testing the Student Management System 608 Summary 613 Review Questions 614 Exercises 615 Programming Problems 616 Applets and Threads 619 Introduction 620 Applets 622 Input to Applets 628 Playing Sounds 634 Displaying Images 637 Loading Images 639 Arrays Revisited 641 Image Maps 645 Threads 649 Case Study: An Example of Multithreading 657 Animation 668 Restrictions 673 Sound and Images with Applications 674 Sound 675 Images 675 Conclusion 676 Summary 677 Review Questions 679 Exercises 680 Programming Problems 682 Sorting, Searching, and Dynamic Data 685 Structures Sorting 686 Class java.util.Arrays---Sort Sequential Search 700 Class java.util.Arrays---Binary Search Linked Lists 708 LinkedList Class 718 Stacks 726 Case Study: Using a Stack for Converting 728 Algebraic Expressions Summary 738 Review Questions 739 Exercises 739 Programming Problems 739 Appendix A Tables 743 A.1 ASCII Characters 743 A.2 Java Primitive Data Types 744 A.3 Operator Priorities 745 A.4 Escape-Sequence Characters 746 Appendix B Syntax of Java 747 B.1 Productions of Lexical Structures 747 B.1 Productions from Types, Values, and 747 Variables B.3 Productions from Names 748 B.4 Productions from Packages 748 B.5 Productions Used Only in the LALR(1) 749 Grammar B.6 Productions from Classes 749 Productions from Class Declarations 749 Productions from Field Declarations 750 Productions from Method Declarations 751 Productions from Static Initializers 751 Productions from Constructor Declarations 751 B.7 Productions from Interfaces 752 Productions from Interface Declarations 752 B.8 Productions from Arrays 752 B.9 Productions from Blocks and Statements 753 B.10 Productions from Expressions 756 Appendix C Answers to Exercises 761 Index 805
Caractéristiques techniques
PAPIER | |
Éditeur(s) | Jones and Bartlett Publishers |
Auteur(s) | Barry J. Holmes, Daniel T. Joyce |
Parution | 01/10/2000 |
Édition | 2eme édition |
Nb. de pages | 826 |
Format | 19 x 23,5 |
Couverture | Broché |
Poids | 1280g |
Intérieur | Noir et Blanc |
EAN13 | 9780763714352 |
Avantages Eyrolles.com
Consultez aussi
- Les meilleures ventes en Graphisme & Photo
- Les meilleures ventes en Informatique
- Les meilleures ventes en Construction
- Les meilleures ventes en Entreprise & Droit
- Les meilleures ventes en Sciences
- Les meilleures ventes en Littérature
- Les meilleures ventes en Arts & Loisirs
- Les meilleures ventes en Vie pratique
- Les meilleures ventes en Voyage et Tourisme
- Les meilleures ventes en BD et Jeunesse