Java Programming

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"

Java Programming, Ninth Edition, provides the beginning programmer with a guide to developing applications using the Java programming language. Java is popular among professional programmers because it can be used to build visually interesting graphical user interface (GUI) and Web-based applications. Java also provides an excellent environment for the beginning programmer—a student can quickly build useful programs while learning the basics of structured and object-oriented programming techniques. This textbook assumes that you have little or no programming experience. It provides a solid background in good object-oriented programming techniques and introduces terminology using clear, familiar language. The programming examples are business examples; they do not assume a mathematical background beyond high school business math. In addition, the examples illustrate only one or two major points; they do not contain so many features that you become lost following irrelevant and extraneous details. Complete, working programs appear frequently in each chapter; these examples help students make the transition from the theoretical to the practical. The code presented in each chapter also can be downloaded from the publisher’s website, so students easily can run the programs and experiment with changes to them. The student using Java Programming, Ninth Edition, builds applications from the bottom up rather than starting with existing objects. This facilitates a deeper understanding of the concepts used in object-oriented programming and engenders appreciation for the existing objects students use as their knowledge of the language advances. When students complete this book, they will know how to modify and create simple Java programs, and they will have the tools to create more complex examples. They also will have a fundamental knowledge about object-oriented programming, which will serve them well in advanced Java courses or in studying other object-oriented languages such as C++, C#, and Visual Basic.

Author(s): Joyce Farrell
Edition: 9th
Year: 2019

Language: English
Pages: 898

Cover......Page 1
Brief Contents......Page 5
Table of Contents......Page 7
Preface......Page 16
Features......Page 22
Assessment......Page 24
Chapter 1: Creating Java Programs......Page 27
Learning Programming Terminology......Page 28
Comparing Procedural and Object-Oriented Programming Concepts......Page 31
Features of the Java Programming Language......Page 36
Analyzing a Java Application That Produces Console Output......Page 38
Compiling a Java Class and Correcting Syntax Errors......Page 48
Running a Java Application and Correcting Logic Errors......Page 55
Adding Comments to a Java Class......Page 58
Creating a Java Application That Produces GUI Output......Page 61
Finding Help......Page 64
Don't Do It......Page 65
Chapter Summary......Page 67
Exercises......Page 71
Chapter 2: Using Data......Page 75
Declaring and Using Constants and Variables......Page 76
Using the boolean Data Type......Page 91
Learning about Floating-Point Data Types......Page 93
Using the char Data Type......Page 94
Using the Scanner Class to Accept Keyboard Input......Page 100
Using the JOptionPane Class to Accept GUI Input......Page 108
Performing Arithmetic Using Variables and Constants......Page 114
Understanding Type Conversion......Page 122
Don't Do It......Page 127
Chapter Summary......Page 128
Exercises......Page 131
Chapter 3: Using Methods, Classes, and Objects......Page 136
Understanding Method Calls and Placement......Page 137
Understanding Method Construction......Page 140
Adding Parameters to Methods......Page 147
Creating Methods That Return Values......Page 153
Learning about Classes and Objects......Page 159
Creating a Class......Page 162
Creating Instance Methods in a Class......Page 164
Declaring Objects and Using Their Methods......Page 171
An Introduction to Using Constructors......Page 176
Understanding That Classes Are Data Types......Page 180
Key Terms......Page 184
Chapter Summary......Page 185
Exercises......Page 189
Chapter 4: More Object Concepts......Page 196
Understanding Blocks and Scope......Page 197
Overloading a Method......Page 205
Learning about Ambiguity......Page 211
Creating and Calling Constructors with Parameters......Page 213
Learning about the this Reference......Page 218
Using static Fields......Page 225
Using Automatically Imported, Prewritten Constants and Methods......Page 232
Understanding Composition and Nested Classes......Page 242
Chapter Summary......Page 246
Exercises......Page 250
Chapter 5: Making Decisions......Page 256
Planning Decision-Making Logic......Page 257
The if and if...else Statements......Page 259
Using Multiple Statements in if and if...else Clauses......Page 265
Nesting if and if...else Statements......Page 271
Using Logical AND and OR Operators......Page 273
Making Accurate and Efficient Decisions......Page 279
Using the switch Statement......Page 284
Using the Conditional and NOT Operators......Page 290
Understanding Operator Precedence......Page 292
Adding Decisions and Constructors to Instance Methods......Page 295
Don't Do It......Page 298
Chapter Summary......Page 299
Exercises......Page 303
Chapter 6: Looping......Page 309
Learning about the Loop Structure......Page 310
Creating while Loops......Page 311
Using Shortcut Arithmetic Operators......Page 322
Creating a for Loop......Page 326
Learning How and When to Use a do...while Loop......Page 332
Learning about Nested Loops......Page 334
Improving Loop Performance......Page 339
Chapter Summary......Page 346
Exercises......Page 350
Chapter 7: Characters, Strings, and the StringBuilder......Page 356
Understanding String Data Problems......Page 357
Using Character Class Methods......Page 358
Declaring and Comparing String Objects......Page 362
Using a Variety of String Methods......Page 368
Learning about the StringBuilder and StringBuffer Classes......Page 378
Don't Do It......Page 384
Chapter Summary......Page 385
Exercises......Page 388
Chapter 8: Arrays......Page 395
Declaring an Array......Page 396
Initializing an Array......Page 401
Using Variable Subscripts with an Array......Page 404
Declaring and Using Arrays of Objects......Page 409
Searching an Array and Using Parallel Arrays......Page 418
Passing Arrays to and Returning Arrays from Methods......Page 425
Chapter Summary......Page 431
Exercises......Page 435
Chapter 9: Advanced Array Concepts......Page 442
Sorting Array Elements Using the Bubble Sort Algorithm......Page 443
Sorting Array Elements Using the Insertion Sort Algorithm......Page 451
Using Two-Dimensional and Other Multidimensional Arrays......Page 456
Using the Arrays Class......Page 464
Using the ArrayList Class......Page 472
Creating Enumerations......Page 475
Chapter Summary......Page 482
Exercises......Page 486
Chapter 10: Introduction to Inheritance......Page 493
Learning about the Concept of Inheritance......Page 494
Extending Classes......Page 498
Overriding Superclass Methods......Page 505
Calling Constructors during Inheritance......Page 509
Accessing Superclass Methods......Page 515
Employing Information Hiding......Page 519
Methods You Cannot Override......Page 521
Key Terms......Page 528
Chapter Summary......Page 529
Exercises......Page 532
Chapter 11: Advanced Inheritance Concepts......Page 539
Creating and Using Abstract Classes......Page 540
Using Dynamic Method Binding......Page 549
Creating Arrays of Subclass Objects......Page 553
Using the Object Class and Its Methods......Page 556
Using Inheritance to Achieve Good Software Design......Page 566
Creating and Using Interfaces......Page 567
Using Anonymous Inner Classes and Lambda Expressions......Page 578
Creating and Using Packages......Page 581
Don't Do It......Page 583
Chapter Summary......Page 584
Exercises......Page 588
Chapter 12: Exception Handling......Page 596
Learning about Exceptions......Page 597
Trying Code and Catching Exceptions......Page 602
Throwing and Catching Multiple Exceptions......Page 611
Using the finally Block......Page 617
Understanding the Advantages of Exception Handling......Page 619
Specifying the Exceptions That a Method Can Throw......Page 622
Tracing Exceptions through the Call Stack......Page 626
Creating Your Own Exception Classes......Page 631
Using Assertions......Page 634
Displaying the Virtual Keyboard......Page 648
Don't Do It......Page 651
Chapter Summary......Page 652
Exercises......Page 656
Chapter 13: File Input and Output......Page 661
Understanding Computer Files......Page 662
Using the Path and Files Classes......Page 664
File Organization, Streams, and Buffers......Page 674
Using Java's IO Classes......Page 677
Creating and Using Sequential Data Files......Page 683
Learning about Random Access Files......Page 689
Writing Records to a Random Access Data File......Page 693
Reading Records from a Random Access Data File......Page 699
Chapter Summary......Page 715
Exercises......Page 719
Chapter 14: Introduction to Swing Components......Page 724
Understanding Swing Components......Page 725
Using the JFrame Class......Page 726
Using the JLabel Class......Page 734
Using a Layout Manager......Page 738
Extending the JFrame Class......Page 741
Adding JTextFields and JButtons to a JFrame......Page 744
Learning about Event-Driven Programming......Page 750
Understanding Swing Event Listeners......Page 759
Using the JCheckBox, ButtonGroup, and JComboBox Classes......Page 762
Don't Do It......Page 774
Chapter Summary......Page 775
Exercises......Page 779
Chapter 15: Using JavaFX and Scene Builder......Page 784
What Is JavaFX?......Page 785
The Life Cycle of JavaFX Applications......Page 786
Understanding JavaFX Structure: Stage, Scene, Panes, and Widgets......Page 788
Creating JavaFX Applications Using Scene Builder......Page 794
Using CSS to Create Visual Effects......Page 804
Creating Animations in JavaFX......Page 811
Chapter Summary......Page 816
Exercises......Page 821
Appendix A: Working with the Java Platform......Page 825
Appendix B: Data Representation......Page 830
Appendix C: Formatting Output......Page 836
Appendix D: Generating Random Numbers......Page 846
Appendix E: Javadoc......Page 852
Glossary......Page 860
Index......Page 879