Home > Store

Imagine! Java: Programming Concepts in Context

Register your product to gain access to bonus material or receive a coupon.

Imagine! Java: Programming Concepts in Context

Book

  • Sorry, this book is no longer in print.
Not for Sale

About

Features

Short, manageable segments. This textbook contains many brief chapters allowing the instructor to present topics in small segments, making the material less intimidating, flexible and easier for students to understand.

An integrated approach. Unlike other texts that address topics in a detached manner, Frank Carrano offers a high level of continuity as students move from concept to concept throughout the book. Concepts and techniques are tightly integrated so that all topics are linked in a logical, contextual way resulting in a more global understanding of the relationship and interaction between the topics.

Covers all key Java programming concepts required by the ACM. This text addresses all CS1 topics normally covered in a one to two-semester CS1 Java course with an objects-early approach (Use in Ch. 4, write in Ch. 6).

“Debugging Interludes” after every major section (7 in the book) present examples of the kind of mistakes that a novice programmer is apt to make and how to repair them.

Succinct and to-the-point. Reviewers have told us that clarity and simplicity are the book’s greatest strength because it improves learning by helping students understand and absorb the material better. The text’s chapters are less cluttered with advanced asides and distractions; students who want to use their textbook to find key information quickly and easily will appreciate that the author has omitted this extraneous material from this text.

Appropriate for CS majors at all levels. While examples are simple, concise, and complete to appeal to a multitude of students, the author also offers small, relevant tidbits that offer the more advanced student an opportunity to pursue a given topic in more detail.

Useful pedagogy. Focused and contextually accurate programming tips, self-test questions, “design decisions”, “A problem solved!”, and notes about programming conventions and style further support Carrano’s proven teaching style.

VideoNotes
VideoNotes are step-by-step video tutorials specifically designed to enhance the programming concepts presented in Carrano, Imagine! Java: Programming Concepts in Context, 1e. Students can view the entire problem-solving process outside of the classroom–when they need help the most. VideoNotes are available with the purchase of a new copy of select titles. Go to www.pearsonhighered.com/videonotes for a brief VideoNotes demo.

Uses detailed diagrams and graphics examples  to make examples fun, relevant and appealing to visual learners.

Uses the Java standard library rather than a custom library.

Superior treatment of recursion.

A focused, methodical, carefully-laid-out presentation of Java concepts.


View an online book tour!

View Frank's recorded webinar session, “Imagine! Success in CS1/Java Programming”.

Frank’s Making it Real blog http://frank-m-carrano.com/blog/ extends his textbooks and lectures to a lively discussion with instructors and students about teaching and learning computer science. Watch a video about Imagine! Java here.

Description

  • Copyright 2011
  • Dimensions: 8" x 10"
  • Pages: 1008
  • Edition: 1st
  • Book
  • ISBN-10: 0-13-147106-6
  • ISBN-13: 978-0-13-147106-1

For one or two-semester  introductory CS1 Java courses taken by CS majors and non-majors.

Based on his inspiring lecture style, author Frank Carrano’s new text, Imagine! Java, engages students immediately with vivid “what if” examples and everyday analogies that keep them engaged and wanting to learn more.

Carrano starts students slowly by presenting concepts in small, manageable chunks that force students to focus on one core concept at a time. Carrano uses engaging repetitive examples to reinforce learning before moving on to more complicated concepts. This approach offers the student an opportunity to establish patterns they can use in their own programs and ultimately develop a more intuitive and sustainable understanding of the programming concepts.

Sample Content

Table of Contents

TABLE OF CONTENTS

1. Introduction

 An Overview of a Computer

        What Can a Computer Do?

        The Components of a Typical Computer

A Computing System’s Software

        The Programming Language Java

        Graphics

Writing, Compiling, and Running a Java Program

        Tools and Resources

        The Steps

2. A First Look at Java

A Simple Java Program

        Identifiers

        Displaying Text

Comments

Data Types

        Primitive Types

        Reference Types

        Variables

        Declarations

        Assignments

Constants

        Unnamed Constants

        Named Constants

Simple Input from the Keyboard

A Problem Solved: Apples by the Box

3. Arithmetic Expressions

Arithmetic Operators

        The Addition and Subtraction Operators, + and -

        The Multiplication Operator *

        The Division Operator /

        The Remainder Operator %

        The Order of Operations

Conversions Between Numeric Data Types

        Coercion

        Casting

A Problem Partially Solved: Day of the Week

Standard Mathematical Methods

A Problem Solved: Wind Chill

Debugging Interlude 1 : The Errors Made by Programmers

Kinds of Errors

Compile-Time Errors

Execution-Time Errors

4. Using Classes and Objects

Introduction

The Class String

        References

        Characters Within Strings

        Joining Strings

        String Methods

        Comparing Characters and Strings

        Using Scanner to Read a String

        A Problem Solved: Processing a String

        Using Scanner to Extract Pieces of a String

        Immutable Strings

The Class Date

The Class BigDecimal

        A Problem Solved: More Apples by the Box

Wrapper Classes

The Class Random

The Class DecimalFormat

The Class JOptionPane

        Using a Dialog Box to Read or Write a String

5. Basic Graphics

Creating a Window

        Getting Ready to Draw

        A Sample Drawing Panel

        Displaying a Panel

The Class Graphics

        The Coordinate System

        Drawing Lines, Shapes, and Text

        Painting Shapes

A Problem Solved: Displaying a Temperature

        The Class Font

The Class Color

A Problem Solved: The Happy Face

6. Class Definitions: The Fundamentals

A Class Definition

        Using the Class Greeter

        Beginning the Class Definition

        Defining Constructors

        Defining Other Methods

        Local Variables

Creating a New Class

        The Design

        The Implementation

Passing Arguments

A Problem Solved: Comparing Classes of Squares

Debugging Interlude 2 : Common Mistakes When Working with Classes

Working with Classes

        A Silent Computational Error

        Undefined Variables of a Class Type

        Constructors

        Omitting the Method toString

A Problem Solved: Extracting Strings

7. Decisions

Flow of Control

The if Statement

        Compound Statements

Basic Comparisons

        Comparing Primitives

        Comparing Objects

A Problem Solved: Day of the Week

The if-else Statement

More Boolean Expressions in Comparisons

A Problem Solved: Leap Years

Assertions

8. Class Definitions: More Details

Boolean-Valued Methods

Private Methods

        Checking the Validity of Data Fields

Final Fields and Static Final Fields

Enumerations

A Problem Solved: Representing Coins

        A Simpler Problem: A Class of Valueless Coins

        Enhancing the Class Definition

Calling a Constructor from a Constructor

9. Classes of Graphical Objects

A Problem Solved: The Happy Face Reprised

        The Class HappyFace: First Version

        The Class HappyFace: Improved Version

A Problem Solved: The Thermometer Reprised

    The Class Thermometer

    Displaying the Thermometer

    Displaying Two Thermometers

10. Multiway Decisions

Nested if Statements

A Problem Solved: Health Club Welcome

The switch Statement

A Problem Solved: Where To?

A Problem Solved: Representing a Temperature

11. Decisions and Object Interaction when Drawing

A Problem Solved: The Thermometer Yet Again

A Problem Solved: Displaying a Random Color

A Problem Solved: Displaying a Row of Dots

A Problem Solved: Where Is the Random Point?

Debugging Interlude 3: Introduction to Testing

Avoiding Mistakes

Displaying a Calendar

A Problem Solved: The Café Sign

        Comparing Two Solutions

12. Repetition

The Logic of a Loop

The while Statement

        A Problem Solved: A Guessing Game

Errors in Loops

        Off-by-One Errors

        Infinite Loops

Boolean Variables in Loops

Nested Loops

        The Scope of a Variable

A Problem Solved: Root of an Equation

13. Repetition Continued

The for Statement

        Using an Enumeration with a for Statement

The do Statement

14. Repetition when Drawing

A Problem Solved: Displaying a Row of Dots (Reprise)

A Problem Solved: The Quahog Shell

A Problem Solved: Circles and Squares

A Problem Solved: The Quilt

A Problem Solved: A Random Walk

Debugging Interlude 4: Debugging Loops

Testing

Debugging Loops

        An Example

Overview of Debugging Tools

        The Command-Line Tool jdb (Optional)

15. Designing Classes

Design Tools

        Choosing Classes

        CRC Cards

        The Unified Modeling Language

Specifying Methods

        Abstraction and Encapsulation

        Comments

        Preconditions and Postconditions

A Problem Solved: Creating a Class to Represent People

        A Class Design

        A Client for Person

        Implementation of the Class Person

Overloaded Methods

Class Relationships

        Reusing Classes

        Coupling and Cohesion

The Modifier static

        Static Fields

        Static Methods

An Enumeration as a Class

16. Object-Oriented Concepts

Java Interfaces

        Writing an Interface

        Some UML Details

        Implementing an Interface

        An Interface as a Data Type

        Casting and Interfaces

        Polymorphism and Interfaces

Inheritance Basics

        The Class Object

        Overriding the Method equals

        Polymorphism and Inheritance

        Extending an Interface

The Comparable Interface

17. Inheritance and Interfaces in Swing and the AWT

The Organization of Major Classes Within the AWT and Swing

Using Button Input

        The Class JButton

        Implementing the Interface ActionListener

        Registering an Action Listener

        Responding to a Button Click

        A Problem Solved: Smile or Frown

Using Mouse Input

        The Interface MouseListener

        A Problem Solved: Changing Color at the Click of a Mouse

        The Interface MouseMotionListener

Using Text Fields

        The Class JTextField

        A Problem Solved: Displaying RGB Colors

Debugging Interlude 5: Debugging Tools

Using Breakpoints and Watches in an IDE

Logging

        The Class Logger

        An Example

More Logging (Optional)

        Message Levels

        Other Logger Methods

        Logging Messages at Levels Lower Than INFO

A Problem Debugged: The Click Disc

18. Arrays

Motivation

Array Basics

        Declaring and Creating an Array

        Declaring and Initializing an Array

        Referencing Array Elements

        Array Index Out of Bounds

Examples of Processing an Array

        Computing Deviations

        Partially Filled Arrays

        Counting Occurrences in an Array

        Finding the Smallest Entry in an Array

        Finding the Index of the Smallest Entry in an Array

        Searching an Array for a Given Entry

More Fundamentals

        Arrays of Objects

        Passing an Array to a Method

        Array Assignments

        Copying an Array

        Methods that Return an Array

        Array Equality

        Time Out

19. An Array-Based Data Structure

The Bag

        A Bag’s Behaviors

Specifying a Bag

        An Interface

Implementing and Testing a Bag

        A Group of Core Methods

        Implementing More Methods

        Methods That Remove Strings

        The Class Definition

20. Arrays Continued

More About One-Dimensional Arrays

        The For-Each Loop Applied to Arrays

        Resizing an Array

        A Problem Solved: An Expandable Bag

        An Arbitrary Number of Arguments

        The Parameter in the Method main

Multidimensional Arrays

        The Basics

        Java’s Representation

        A Problem Solved: Processing a Digital Image

        Arrays of Three or More Dimensions

        Ragged Arrays

Parallel Arrays

Debugging Interlude 6 : Debugging Arrays

An Unallocated Array

A Silent Error

        The Method toArray as a Stub

Array Index Out of Bounds

        Defining the Method toArray

Another Silent Error

        The Method remove

21. Array Lists

The List

        The Behaviors of a List

The Interface List

The Class ArrayList

        An Array List’s Size and Capacity

        Creating an Array List

        Adding Entries to a List

        Retrieving Entries

        Searching for Entries

        Replacing Entries

        Removing Entries

Arrays Versus Array Lists

22. Arrays when Drawing

Polygons

        Polygon Methods in the Class Graphics

        The Class Polygon

A Class of Right Triangles

        Data Fields and Methods

        The Class Point

        Specifications for the Class RightTriangle

        Implementing RightTriangle

A Problem Solved: A New Quilt

        A Class of Squares

        A Class of Quilts

A Problem Solved: Connecting the Dots

        Using Parallel Arrays of Coordinates

        Using an Array of Points

        Using a List of Points

A Problem Solved: The Keypad

        Establishing the Design

        The Class OutputPanel

        The Class KeypadPanel

        The Class KeypadDriver

23. Sorting and Searching

Sorting

        Selection Sort

        Detecting When an Array Is Sorted

        Insertion Sort

        Sorting Objects

        Sorting Methods in the Java Class Library

Searching

        A Linear Search of an Unsorted Array

        A Linear Search of a Sorted Array

        A Binary Search of a Sorted Array

        Searching Methods in the Java Class Library

The Performance of Algorithms

        The Performance of Sorting Methods

        The Performance of Searching Methods

24. Recursion

What Is Recursion?

        Example: The Countdown

        Implementation Details

Tracing a Recursive Method

Recursive Methods That Return a Value

A Problem Solved: Speaking the Digits in a Number

A Problem Solved: Writing a Number in Words

Recursion Versus Iteration

        Fibonacci Numbers: A Poor Use of Recursion

Kinds of Recursion

        Tail Recursion

        Direct, Indirect, and Mutual Recursion

25. Recursive Array Processing

Basic Techniques

Searching an Array Recursively

        A Recursive Linear Search

        Searching a Bag Recursively

        A Recursive Binary Search

A Recursive Merge Sort

        Merging Arrays

        The Merge Sort Algorithm

        A Merge Sort Method

        Merge Sort in the Java Class Library

        The Performance of Merge Sort (Optional)

Recursion Versus Iteration

        Binary Search

        Merge Sort

26. Recursive Drawings

A Problem Solved: The Target

A Problem Solved: Painting Like Mondrian

A Problem Solved: The Sierpinski Carpet

Debugging Interlude 7 : Debugging Recursive Methods

Infinite Recursion

        Carpeting Trouble: Base-Case Omission

Incorrect Results

        Sorting and Merging, Merging and Sorting

        Verbalizing Integers: Saying Too Much

27. Inheritance Continued

A Problem Solved: Designing a Hierarchy of Classes

The Basic Rules of Inheritance

        What Is Inherited?

        Constructors of the Superclass and Subclass

        Protected Access

        The Implementation So Far

        Packages and Package Access

        Type Compatibility

        Casting Object Types

Abstract Classes and Methods

        Interfaces Versus Abstract Classes

Overriding Methods, Hiding Methods

        Overriding Revisited

        Hiding Methods

Final Classes and Methods

28. Exceptions

The Basics

        Kinds of Exceptions

        Errors

Handling an Exception

        Postpone Handling: The throws Clause

        Handle It Now: The try-catch Blocks

        Multiple catch Blocks

Throwing an Exception

Programmer Defined Exception Classes

        A Sample Definition

        Using Our Own Exception Class

A Problem Solved: Groups of People

Inheritance and Exceptions

The finally Block

29. Text Files

Preliminaries

        Why Files?

        Streams

        The Kinds of Files

        File Names

Creating a Text File

        Opening, Writing, and Closing a Text File

        A Class for Creating Text Files

        A Problem Solved: Creating a Text File of Colleges and Universities

Reading a Text File

        Opening, Reading, and Closing a Text File

        A Problem Solved: Displaying a List of Colleges and Universities

        Reading a Text File More Than Once

Appending Data to an Existing Text File

Changing Existing Data in a Text File

ONLINE CHAPTERS

30. Sequential Binary Files

Creating a Binary File of Objects

    Opening, Writing, and Closing a Binary File

    A Class for Creating a Binary File of Objects

    A Problem Solved: Creating a Binary File of Colleges and Universities

Reading a Binary File of Objects

    Opening, Reading, and Closing a Binary File

    A Problem Solved: Displaying a List of Colleges and Universities

Arrays in Binary Files

    Writing Arrays to a Binary File

    Reading Arrays From a Binary File

Binary Files of Primitive Data

    Writing Primitive Data to a Binary File

    Reading Primitive Data From a Binary File

31. Random-Access Files

The File Pointer

Basic Operations for a Random Access File

        Opening a Random-Access File

        Writing to a Random-Access File

        Reading a Random-Access File

        Recording File-Pointer Values

A Problem Solved: A Glossary of Terms

        Creating the Glossary

        Accessing the Glossary

32. Generics and Collections

Generics

        Generic Types Within a Class Definition

        Generic Types Within an Interface

        A Problem Solved: A Bag of Objects

Collections

        Abstract Data Types

        Data Structures

        The Java Collections Framework

APPENDICES

A. Getting Java for Free

B. Reserved Words

C. Unicode Characters

D. Documentation and Programming Style

Naming Variables and Classes

Indenting

Comments

    Single-Line Comments

    Comment Blocks

    When to Write Comments

    Java Documentation Comments

    Running javadoc

E. Cloning

Cloning an Object

Cloning an Array

Glossary

Index

 

Updates

Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020