Java Introduction to Problem Solving and Programming & MyProgrammingLab with Pearson eText Student Access Code Card for Java

  • ISBN13:


  • ISBN10:


  • Edition: 6th
  • Format: Package
  • Copyright: 2011-06-06
  • Publisher: Pearson
  • Purchase Benefits
  • Free Shipping On Orders Over $35!
    Your order must be $35 or more to qualify for free economy shipping. Bulk sales, PO's, Marketplace items, eBooks and apparel do not qualify for this offer.
  • Get Rewarded for Ordering Your Textbooks! Enroll Now
List Price: $163.47


This package contains Java: An Introduction to Problem Solving and Programming, 6e,an access code for MyProgrammingLab, and a Pearson eText student access code card for Java: An Introduction to Problem Solving and Programming, 6e. Java: An Introduction to Problem Solving and Programming, 6e, is ideal for introductory Computer Science courses using Java, and other introductory programming courses in departments of Computer Science, Computer Engineering, CIS, MIS, IT, and Business. Students are introduced to object-oriented programming and important concepts such as design, testing and debugging, programming style, interfaces inheritance, and exception handling. The Java coverage is a concise, accessible introduction that covers key language features. Objects are covered thoroughly and early in the text, with an emphasis on application programs over applets. MyProgrammingLab is a database of programming exercises correlated to specific Pearson CS1/Intro to Programming textbooks. The exercises are short, focused on a particular programming topic, and are assignable and automatically evaluated. MyProgrammingLab provides immediate, personalized feedback which helps students master the syntax, semantics and basic usage of the programming language, freeing instructors to focus on problem-solving strategies, design and analysis, abstraction, algorithms, and style. Learn more atwww.myprogramminglab.com.

Author Biography

Walter Savitch received his Ph.D. degree in Mathematics from the University of California at Berkeley in 1969. Since that time he has been on the faculty at the University of California at San Diego and is currently a Professor of Computer Science and director of the Interdisciplinary Ph.D. Program in Cognitive Science. Professor Savitch’s research areas include complexity theory, formal language theory, computational linguistics, and the development of computer science education materials. In addition to writing numerous research articles and involvement in other editorial projects, he has written a number of well-known computer science textbooks, including Pascal, Ada, and C++ CS1 and CS2 textbooks.

Contributing author, Kenrick Mock, is an Associate Professor at the University of Alaska–Anchorage. He has also taught at Washington State University, Portland State University, and the University of California–Davis. He teaches undergraduate computer science courses across the curriculum including introductory C++, Java™, Visual Basic® for non-programmers, algorithms, computer security, and artificial intelligence. With the Coastal Marine Institute at UAA, he helped develop a computer system to aid in research about Alaska sea ice and the atmosphere. Before becoming a teacher, Mock was a research scientist and software engineer at Intel™. He received a PhD in computer science from UC Davis.

Table of Contents

Chapter 1 Introduction to Computers and Java 1
1.1 Computer Basics 2
Hardware and Memory 3
Programs 6
Programming Languages, Compilers, and Interpreters 7
Java Bytecode 9
Class Loader 11
1.2 A Sip of Java 12
History of the Java Language 12
Applications and Applets 13
A First Java Application Program 14
Writing, Compiling, and Running a Java Program 19
1.3 Programming Basics 21
Object-Oriented Programming 21
Algorithms 25
Testing and Debugging 27
Software Reuse 28
1.4 Graphics Supplement 30
A Sample Graphics Applet 30
Size and Position of Figures 32
Drawing Ovals and Circles 34
Drawing Arcs 35
Running an Applet 37

Chapter 2 Basic Computation 47
2.1 Variables and Expressions 48
Variables 49
Data Types 51
Java Identifiers 53
Assignment Statements 55
Simple Input 58
Simple Screen Output 60
Constants 60
Named Constants 62
Assignment Compatibilities 63
Type Casting 65
Arithmetic Operators 68
Parentheses and Precedence Rules 71
Specialized Assignment Operators 72
Case Study: Vending Machine Change 74
Increment and Decrement Operators 79
More About the Increment and Decrement Operators 80
2.2 The Class String 81
String Constants and Variables 81
Concatenation of Strings 82
String Methods 83
String Processing 85
Escape Characters 88
The Unicode Character Set 89
2.3 Keyboard and Screen I/O 91
Screen Output 91
Keyboard Input 94
Other Input Delimiters (Optional) 99
Formatted Output with printf (Optional) 101
2.4 Documentation and Style 103
Meaningful Variable Names 103
Comments 104
Indentation 107
Using Named Constants 107
2.5 Graphics Supplement 109
Style Rules Applied to a Graphics Applet 110
Creating a Java GUI Application with the JFrame Class 110
Introducing the Class JOptionPane 113
Reading Input as Other Numeric Types 123
Programming Example: Change-Making Program
with Windowing I/O 124

Chapter 3 Flow of Control: Branching 137
3.1 The if-else Statement 138
The Basic if-else Statement 139
Boolean Expressions 145
Comparing Strings 150
Nested if-else Statements 155
Multibranch if-else Statements 157
Programming Example: Assigning Letter Grades 159
Case Study: Body Mass Index 162
The Conditional Operator (Optional) 165
The exit Method 165
3.2 The Type boolean 166
Boolean Variables 167
Precedence Rules 168
Input and Output of Boolean Values 171
3.3 The switch Statement 173
Enumerations 179
3.4 Graphics Supplement 180
Specifying a Drawing Color 181
A Dialog Box for a Yes-or-No Question 184

Chapter 4 Flow of Control: Loops 195
4.1 Java Loop Statements 196
The while Statement 197
The do-while Statement 200
Programming Example: Bug Infestation 205
Programming Example: Nested Loops 211
The for Statement 213
Declaring Variables within a for Statement 219
Using a Comma in a for Statement (Optional) 220
The for-each Statement 222
4.2 Programming with Loops 222
The Loop Body 223
Initializing Statements 224
Controlling the Number of Loop Iterations 225
Case Study: Using a Boolean Variable to End a Loop 227
Programming Example: Spending Spree 229
The break Statement and continue Statement in Loops
(Optional) 232
Loop Bugs 235
Tracing Variables 237
Assertion Checks 239
4.3 Graphics Supplement 241
Programming Example: A Multiface Applet 241
The drawstring Method 247

Chapter 5 Defining Classes and Methods 261
5.1 Class and Method Definitions 263
Class Files and Separate Compilation 265
Programming Example: Implementing a Dog Class 265
Instance Variables 266
Methods 269
Defining void Methods 272
Defining Methods That Return a Value 273
Programming Example: First Try at Implementing a Species Class 278
The Keyword this 282
Local Variables 284
Blocks 286
Parameters of a Primitive Type 287
5.2 Information Hiding and Encapsulation 293
Information Hiding 294
Precondition and Postcondition Comments 294
The public and private Modifiers 296
Programming Example: A Demonstration of Why Instance
Variables Should Be Private 299
Programming Example: Another Implementation of a Class
of Rectangles 300
Accessor Methods and Mutator Methods 302
Programming Example: A Purchase Class 306
Methods Calling Methods 310
Encapsulation 316
Automatic Documentation with javadoc 319
UML Class Diagrams 320
5.3 Objects and References 321
Variables of a Class Type 322
Defining an equals Method for a Class 327
Programming Example: A Species Class 331
Boolean-Valued Methods 334
Case Study: Unit Testing 336
Parameters of a Class Type 338
Programming Example: Class-Type Parameters Versus
Primitive-Type Parameters 342
5.4 Graphics Supplement 346
The Graphics Class 346
Programming Example: Multiple Faces, but with a Helping
Method 348
The init Method 352
Adding Labels to an Applet 352

Chapter 6 More About Objects and Methods 373
6.1 Constructors 375
Defining Constructors 375
Calling Methods from Constructors 384
Calling a Constructor from Other Constructors (Optional) 387
6.2 Static Variables and Static Methods 389
Static Variables 389
Static Methods 390
Dividing the Task of a main Method into Subtasks 397
Adding a main Method to a Class 398
The Math Class 400
Wrapper Classes 403
6.3 Writing Methods 409
Case Study: Formatting Output 409
Decomposition 415
Addressing Compiler Concerns 416
Testing Methods 418
6.4 Overloading 420
Overloading Basics 420
Overloading and Automatic Type Conversion 423
Overloading and the Return Type 426
Programming Example: A Class for Money 428
6.5 Information Hiding Revisited 435
Privacy Leaks 435
6.6 Enumeration as a Class 439
6.7 Packages 441
Packages and Importing 441
Package Names and Directories 443
Name Clashes 446
6.8 Graphics Supplement 447
Adding Buttons 447
Event-Driven Programming 449
Programming Buttons 449
Programming Example: A Complete Applet with Buttons 453
Adding Icons 456
Changing Visibility 458
Programming Example: An Example of Changing Visibility 458

Chapter 7 Arrays 479
7.1 Array Basics 481
Creating and Accessing Arrays 482
Array Details 485
The Instance Variable length 488
More About Array Indices 491
Initializing Arrays 494
7.2 Arrays in Classes and Methods 495
Case Study: Sales Report 495
Indexed Variables as Method Arguments 503
Entire Arrays as Arguments to a Method 505
Arguments for the Method main 507
Array Assignment and Equality 508
Methods That Return Arrays 511
7.3 Programming with Arrays and Classes 515
Programming Example: A Specialized List Class 515
Partially Filled Arrays 523
7.4 Sorting and Searching Arrays 525
Selection Sort 525
Other Sorting Algorithms 529
Searching an Array 531
7.5 Multidimensional Arrays 532
Multidimensional-Array Basics 533
Multidimensional-Array Parameters and Returned Values 536
Java’s Representation of Multidimensional Arrays 539
Ragged Arrays (Optional) 540
Programming Example: Employee Time Records 542
7.6 Graphics Supplement 548
Text Areas and Text Fields 548
Programming Example: A Question-and-Answer Applet 548
The Classes JTextArea and JTextField 551
Drawing Polygons 553

Chapter 8 Inheritance, Polymorphism and Interfaces 575
8.1 Inheritance Basics 576
Derived Classes 578
Overriding Method Definitions 582
Overriding Versus Overloading 583
The final Modifier 583
Private Instance Variables and Private Methods of a Base Class 584
UML Inheritance Diagrams 586
8.2 Programming with Inheritance 589
Constructors in Derived Classes 589
The this Method–Again 591
Calling an Overridden Method 591
Programming Example: A Derived Class of a Derived Class 592
Another Way to Define the equals Methods in Undergraduate 597
Type Compatibility 597
The Class Object 602
A Better equals Method 604
8.3 Polymorphism 606
Dynamic Binding and Inheritance 606
Dynamic Binding with toString 609
Class Interfaces 611
Java Interfaces 612
Implementing an Interface 613
An Interface as a Type 615
Extending an Interface 618
Case Study: Character Graphics 619
Case Study: The Comparable Interface 632
Abstract Classes 636
8.5 Graphics Supplement 638
The Class JApplet 639
The Class JFrame 639
Window Events and Window Listeners 642
The ActionListener Interface 644
What to Do Next 644

Chapter 9 Exception Handling 657
9.1 Basic Exception Handling 658
Exceptions in Java 659
Predefined Exception Classes 669
9.2 Defining Your Own Exception Classes 671
9.3 More About Exception Classes 681
Declaring Exceptions (Passing the Buck) 681
Kinds of Exceptions 684
Errors 686
Multiple Throws and Catches 687
The finally Block 693
Rethrowing an Exception (Optional) 694
Case Study: A Line-Oriented Calculator 695
9.4 Graphics Supplement 707
Exceptions in GUIs 707
Programming Example: A JFrame GUI Using Exceptions 707

Chapter 10 Streams and File I/O 725
10.1 An Overview of Streams and File I/O 727
The Concept of a Stream 727
Why Use Files for I/O? 728
Text Files and Binary Files 728
10.2 Text-File I/O 730
Creating a Text File 730
Appending to a Text File 736
Reading from a Text File 738
10.3 Techniques for any File 741
The Class File 741
Programming Example: Reading a File Name
from the Keyboard 741
Using Path Names 743
Methods of the Class File 744
Defining a Method to Open a Stream 746
Case Study: Processing a Comma-Separated Values File 748
10.4 Basic Binary-File I/O 751
Creating a Binary File 751
Writing Primitive Values to a Binary File 753
Writing Strings to a Binary File 756
Some Details About writeUTF 757
Reading from a Binary File 759
The Class EOFException 764
Programming Example: Processing a File of Binary Data 766
10.5 Binary-File I/O with Objects and Arrays 771
Binary-File I/O with Objects of a Class 771
Some Details of Serialization 775
Array Objects in Binary Files 776
10.6 Graphics Supplement 779
Programming Example: A JFrame GUI for Manipulating Files 779

Chapter 11 Recursion 799
11.1 The Basics of Recursion 800
Case Study: Digits to Words 803
How Recursion Works 808
Infinite Recursion 812
Recursive Methods Versus Iterative Methods 814
Recursive Methods That Return a Value 816
11.2 Programming with Recursion 820
Programming Example: Insisting That User Input Be Correct 820
Case Study: Binary Search 822
Programming Example: Merge Sort–A Recursive Sorting Method 830

Chapter 12 Dynamic Data Structures and Generics 847
12.1 Array-Based Data Structures 849
The Class ArrayList 850
Creating an Instance of ArrayList 850
Using the Methods of ArrayList 852
Programming Example: A To-Do List 856
Parameterized Classes and Generic Data Types 859
The Collection Interface 860
The Class HashSet 861
The Map Interface 862
The Class HashMap 862
12.3 Linked Data Structures 865
The Class LinkedList 865
Linked Lists 866
Implementing the Operations of a Linked List 869
A Privacy Leak 876
Inner Classes 877
Node Inner Classes 878
Iterators 878
The Java Iterator Interface 890
Exception Handling with Linked Lists 890
Variations on a Linked List 892
Other Linked Data Structures 894
12.4 Generics 895
The Basics 895
Programming Example: A Generic Linked List 898

1 Getting Java 917
2 Running Applets 918
3 Protected and Package Modifiers 920
4 The DecimalFormat Class 921
Other Pattern Symbols 922
5 Javadoc 925
Commenting Classes for Use within javadoc 925
Running javadoc 926
6 Differences Between C++ and Java 928
Primitive Types 928
Strings 928
Flow of Control 928
Testing for Equality 929
main Method (Function) and Other Methods 929
Files and Including Files 929
Class and Method (Function) Definitions 930
No Pointer Types in Java 930
Method (Function) Parameters 930
Arrays 930
Garbage Collection 931
Other Comparisons 931
7 Unicode Character Codes 932
Index 933

Rewards Program

Write a Review