RETURN TO SEARCH RESULTS

The Practice and Philosophy of Object-Oriented Programming in Java

Author(s): Drue Coles

Edition: 1

Copyright: 2020

Pages: 454

CHOOSE YOUR FORMATHelp Me Choose

Details: Electronic Delivery EBOOK | 180 days |

Java is a programming language and software platform used by millions of developers worldwide to create applications for everything from mobile devices and desktop comput­ers to large-scale distributed systems and supercomputers. The design and implementation of a software system can be a massively complex process, like building a skyscraper, with teams of developers working for years to design, code, test, debug, configure, and deploy the various components of the system. This complexity can be managed through the use of object orientation, a philosophy of programming based on the creation of abstract bundles of data and behaviors that model meaningful entities in the problem domain.

This book introduces readers with no prior programming experience to the practice and philosophy of object-oriented programming in Java. After an introduction, the book is partitioned into two parts. Part 1 develops general programming concepts with an object-based perspective through examples involving the use of objects. Objects are defined by classes, and in the first part of the book we work with preexisting classes available to all Java programmers through the Java Class Library. In Part 2, we learn how to create our own classes, which amounts to extending the Java language with useful new data types. This activity brings us into contact with the conceptual cornerstones of object-oriented programming. Practical features of the Java language and class library that rest clearly and firmly upon these cornerstones are explored in the rest of the book.

The treatment of important concepts is structured around complete working examples of properly documented code following industry standards for coding style. The exam­ples have evolved over long years of classroom experience, benefiting especially from col­laborative experimentation with curious and imaginative students. Complementing the examples are the practice problems at the end of each chapter. Consistent practice is the single most important ingredient of success in almost every difficult endeavor, from pro­gramming to swimming to playing a musical instrument, so no effort has been spared to provide a large and diverse collection of practice problems, easy ones and challenging ones, often with connections to mathematics and the natural sciences.

This book is not intended to serve as a comprehensive reference to Java or as a text­book for a course on data structures and algorithms. Computer science students and other prospective practitioners of Java will eventually need to learn about concurrency, networking, streams, database programming, and much more. Although this book does not head in those directions, it points the way. It provides a foundation for the study of advanced concepts and techniques in Java and flattens the learning curve for the study of other object-oriented languages. It is not a grand tour of all things in Java, but a Java-based introduction to programming guided by the light of object orientation.

By the end of this book the reader will understand

  • Objects, classes, and methods
  • General programming concepts and techniques
  • Community standards for coding style and documentation in Java
  • Inheritance and polymorphism
  • Interface types and event-handling
  • Exception handling and basic elements of file I/O

 

And the reader will be able to

  • Write properly documented Java code
  • Create and use objects defined by classes in the standard Java library
  • Solve programming problems of moderate complexity using loops and arrays
  • Apply general principles of good programming to write clear and modular code
  • Implement custom classes
  • Use core collection interfaces
  • Implement interfaces for event handling
  • Use nested classes and lambda expressions
  • Create useful new types through inheritance
  • Design and implement graphical user interfaces
  • Handle exceptions and perform basic I/O with text files

Preface
About the Author

Introduction

Chapter 1: The Programming Environment

1.1 What is Programming
1.1.1 Machine View
1.1.2 Low-Level Programming
1.1.3 High-Level Programming
1.1.4 A Note on Terminology
1.1.5 Review Questions

1.2 The Story of Java
1.2.1 Design Goals of Java
1.2.2 A First Look at Objects and Classes
1.2.3 What is a Philosophy of Programming?
1.2.4 Review Questions

1.3 Installing Java
1.3.1 The Java Virtual Machine
1.3.2 The Java Development Kit
1.3.3 Integrated Development Environments
1.3.4 Getting Started
1.3.5 Review Questions

1.4 The Java Class Library
1.4.1 Packages and Modules
1.4.2 Application Programming Interface (API)
1.4.3 Discovering Methods
1.4.4 Review Questions

Chapter 2: Anatomy of a Simple Program

2.1 An Empty Program
2.1.1 Basic Concepts
2.1.2 Review Questions

2.2 Generating Output
2.2.1 Syntax Errors
2.2.2 Logic Errors
2.2.3 Review Questions

2.3 Variables and Arithmetic
2.3.1 Primitive Types
2.3.2 Variables
2.3.3 Static Typing
2.3.4 Arithmetic
2.3.5 Choosing Variable Names
2.3.6 Review Questions

2.4 Style and Documentation
2.4.1 Internal Documentation
2.4.2 Coding Style
2.4.3 Comments in Java
2.4.4 Javadoc​
2.4.5 Review Questions

Part 1: Programming with an Object-Based Perspective

Chapter 3: Using Objects

3.1 Strings
3.1.1 Strings are Objects
3.1.2 Reference Types
3.1.3 Strings are Immutable
3.1.4 Other String Methods
3.1.5 Anonymous Objects
3.1.6 Escape Sequences
3.1.7 Unicode
3.1.8 Review Questions

3.2 Constructors
3.2.1 Creating Objects
3.2.2 Import Statements
3.2.3 Mutable Sequences of Characters
3.2.4 Review Questions

3.3 Random Numbers
3.3.1 Pseudorandom Numbers
3.3.2 Factory Methods
3.3.3 Review Questions

3.4 Keyboard Input
3.4.1 Using Scanners
3.4.2 Static Methods
3.4.3 Type Conversions: Casts and Promotions
3.4.4 Overflow
3.4.5 Review Questions

3.5 Large Numbers
3.5.1 Creating BigIntegers​
3.5.2 Calculating with BigIntegers​
3.5.3 Class Constants
3.5.4 Review Questions

3.6 Formatting Numbers
3.6.1 Basic Concepts
3.6.2 Review Questions

3.7 Graphics
3.7.1 Widget Toolkits​
3.7.2 JavaFX​
3.7.3 Getting Started
3.7.4 Extending a Class
3.7.5 Making a Scene
3.7.6 Annotations
3.7.7 Drawing Shapes
3.7.8 Final Variables
3.7.9 Colors
3.7.10 Working with Rectangles
3.7.11 Adding Nodes to the Scene
3.7.12 Polygons
3.7.13 Circles, Ellipses, and Text
3.7.14 Review Questions

3.8 Practice Problems
3.8.1 String Manipulation
3.8.2 Simple Arithmetic Calculations
3.8.3 Arithmetic Calculations with Formatted Output
3.8.4 Monetary Calculations
3.8.5 Large Numbers
3.8.6 The Java Date/Time API
3.8.7 Graphics with JavaFX

Chapter 4: Helper Methods

4.1 Modularity
4.1.1 Implementing a Helper Method
4.1.2 Review Questions

4.2 Illustrations
4.2.1 Creating Shapes with Randomized Properties
4.2.2 Scale Transitions
4.2.3 Review Questions

4.3 Practice Problems

Chapter 5: Decisions

5.1 Boolean Expressions
5.1.1 Operators and Expressions
5.1.2 Review Questions

5.2 if Statements
5.2.1 Basic Concepts
5.2.2 Review Questions

5.3 if-else Statements
5.3.1 Ternary Operator
5.3.2 if-else Chains
5.3.3 Review Questions

5.4 Equality Operators
5.4.1 Basic Concepts
5.4.2 Review Questions

5.5 Conditional Operators
5.5.1 Conditional OR
5.5.2 Conditional AND
5.5.3 Review Questions

5.6 Unary Operators
5.6.1 The Negation Operator
5.6.2 Compound Assignment Operators
5.6.3 Increment and Decrement Operators
5.6.4 Review Questions

5.7 switch Statements
5.7.1 Basic Concepts
5.7.2 Review Questions

5.8 Practice Problems

Chapter 6: Loops

6.1 while Loops
6.1.1 do-while Loops
6.1.2 Review Questions

6.2 for Loops
6.2.1 Game of Craps
6.2.2 Fractal Generator
6.2.3 Review Questions

6.3 Monte Carlo Simulations
6.3.1 Random Walks
6.3.2 Approximating π
6.3.3 The Probability of Winning at Craps
6.3.4 Returning Two Values from a Method?
6.3.5 Communicating through Static Fields
6.3.6 Review Questions

6.4 Nested Loops
6.4.1 Basic Concepts
6.4.2 Review Questions

6.5 Practice Problems
6.5.1 Console Applications without Nested Loops
6.5.2 Monte Carlo Simulations
6.5.3 Graphics Applications without Nested Loops
6.5.4 Console Applications with Nested Loops
6.5.5 Graphics Applications with Nested Loops

Chapter 7: Arrays

7.1 Linear Arrays
7.1.1 Motivation
7.1.2 Using Arrays
7.1.3 Initializer Lists
7.1.4 Command-Line Arguments
7.1.5 Review Questions

7.2 for-each Loops
7.2.1 Basic Concepts
7.2.2 Review Questions

7.3 Copying Arrays
7.3.1 Basic Concepts
7.3.2 Review Questions

7.4 Balls into Bins
7.4.1 The Birthday Paradox
7.4.2 Randomized Playlist
7.4.3 Review Questions

7.5 ArrayLists
7.5.1 Generic Types
7.5.2 Wrapper Classes
7.5.3 Review Questions

7.6 Two-Dimensional Arrays
7.6.1 Motivation
7.6.2 Arrays of Arrays
7.6.3 Applications
7.6.4 Ragged Arrays
7.6.5 Multidimensional Arrays
7.6.6 Review Questions

7.7 Practice Problems
7.7.1 Linear Arrays
7.7.2 Monte Carlo Simulations
7.7.3 ArrayLists

Part 2: Cornerstones of Object-Oriented Programming

Chapter 8: Custom Classes

8.1 Abstraction and Encapsulation
8.1.1 Primitive vs. Complex Types
8.1.2 Models and Abstraction
8.1.3 Encapsulation and Information Hiding
8.1.4 Review Questions

8.2 Instance Variables
8.2.1 Instance vs. Class (Static) Variables
8.2.2 Declaring Instance Variables
8.2.3 The Scope of a Variable
8.2.4 Review Questions

8.3 Constructors
8.3.1 Constructors vs. Methods
8.3.2 Shadowing
8.3.3 Overloading Constructors
8.3.4 Review Questions

8.4 Methods
8.4.1 Instance vs. Static Methods
8.4.2 The Public Interface and Cohesion
8.4.3 The Implicit Parameter
8.4.4 Review Questions

8.5 Cup of Dice
8.5.1 Basic Concepts
8.5.2 Review Questions

8.6 Game of Fifteen
8.6.1 The Back End
8.6.2 The Object Class
8.6.3 The Front End
8.6.4 Review Questions

8.7 Rational Numbers
8.7.1 Overriding equals
8.7.2 Overriding hashCode​
8.7.3 Review Questions

8.8 Practice Problems
8.7.1 Games with Character Sequences
8.7.2 Games with Two-Dimensional Arrays

Chapter 9: Interfaces and Event Handling

9.1 Motivating the Concept of an Interface
9.1.1 Basic Concepts
9.1.2 Review Questions

9.2 Defining and Using an Interface
9.2.1 What is an Interface?
9.2.2 Implementing an Interface
9.2.3 Using an Interface
9.2.4 Late Binding and Polymorphism
9.2.5 Review Questions

9.3 The Comparable Interface
9.3.1 Raw Types
9.3.2 Sorting Arrays
9.3.3 Natural Ordering
9.3.4 Rational Numbers
9.3.5 Review Questions

9.4 The Comparator Interface
9.4.1 Basic Concepts
9.4.2 Review Questions

9.5 Collection Interfaces
9.5.1 Lists
9.5.2 Sets
9.5.3 Maps
9.5.4 The Iterable<E> Interface
9.5.5 Review Questions

9.6 Action Events
9.6.1 Events
9.6.2 Nested Classes
9.6.3 Handling Action Events
9.6.4 Styling Nodes
9.6.5 Handling Action Events (More Examples)
9.6.6 Other Action Event Targets
9.6.7 Review Questions

9.7 Input Events
9.7.1 Basic Concepts
9.7.2 Review Questions

9.8 Lambda Expressions
9.8.1 Functional Programming in Java
9.8.2 Anonymous Classes
9.8.3 Anonymous Methods
9.8.4 Review Questions

9.9 Practice Problems
9.9.1 Implementing the Comparable<T> Interface
9.9.2 Implementing the Comparator<T> Interface
9.9.3 Using the EventHandler<T> Interface
9.9.4 Games Played on 2D Arrays
9.9.5 Property Binding

Chapter 10: Inheritance and Polymorphism

10.1 Type Inheritance
10.1.1 Basic Concepts
10.1.2 Review Questions

10.2 Code Inheritance
10.2.1 Code Reuse with Composition
10.2.2 Multiple Inheritance
10.2.3 Review Questions

10.3 Abstract Classes
10.3.1 Rational Numbers
10.3.2 A Small Inheritance Hierarchy
10.3.3 Protected Access
10.3.4 Review Questions

10.4 Subclass Construction
10.4.1 Top-Down Constructor Chaining
10.4.2 Constructor Chaining within the Same Class
10.4.3 Invoking Overridden Methods
10.4.4 Completing the Pet Hierarchy
10.4.5 Review Questions

10.5 Polymorphism Revisited
10.5.1 Upcasting​
10.5.2 Downcasting​
10.5.3 The instanceOf Operator
10.5.4 Review Questions

10.6 Extending Library Classes
10.6.1 Basic Concepts
10.6.2 Review Questions

10.7 An Ecological Simulation
10.7.1 Enumerated Types
10.7.2 Creature Classes
10.7.3 Simulation Code
10.7.4 Review Questions

10.8 Practice Problems

Chapter 11: Exception Handling

11.1 Exceptional Events
11.1.1 Basic Concepts
11.1.2 Benefits of Formal Exception Handling
11.1.3 The Call Stack and Stack Traces
11.1.4 Review Questions

11.2 Throwing and Catching Exceptions
11.2.1 Errors vs. Exceptions
11.2.2 throw Statements
11.2.3 try-catch Blocks
11.2.4 Review Questions

11.3 Checked and Unchecked Exceptions
11.3.1 Informal Characterization
11.3.2 A Closer Look
11.3.3 Formal Definition
11.3.4 Review Questions

11.4 The Catch or Specify Requirement
11.4.1 A Special Rule for Checked Exceptions
11.4.2 Controversy
11.4.3 Review Questions

11.5 Reading and Writing Text Files
11.5.1 Binary vs. Text Files
11.5.2 Byte Streams
11.5.3 Character Streams
11.5.4 Line-Oriented Character Streams
11.5.5 Formatted I/O
11.5.6 Review Questions

11.6 Practice Problems

References

Drue Coles

Drue Coles is a Professor of Computer Science at Bloomsburg University of Pennsylvania, where he teaches Java, C++, mobile device application development, analysis of algorithms, and other courses. He holds a PhD in Computer Science and an MS in Computer Information Systems, both from Boston University, and is an Oracle Certified Associate Java SE Programmer. Drue has been teaching object-oriented programming for 23 years, and since 2004 he has enjoyed special responsibility for introducing new Computer Science majors at Bloomsburg University to object-oriented programming in Java.

Related ISBN's: 9781792411847, 9781792451799

Ebook

$60.00

QTY:

ISBN 9781792411847

Details Electronic Delivery EBOOK 180 days