26.07.2013 Views

Java How to Program Fourth Edition - DCC

Java How to Program Fourth Edition - DCC

Java How to Program Fourth Edition - DCC

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 8 Object-Based <strong>Program</strong>ming 379<br />

Outline<br />

8.1 Introduction<br />

8.2 Implementing a Time Abstract Data Type with a Class<br />

8.3 Class Scope<br />

8.4 Controlling Access <strong>to</strong> Members<br />

8.5 Creating Packages<br />

8.6 Initializing Class Objects: Construc<strong>to</strong>rs<br />

8.7 Using Overloaded Construc<strong>to</strong>rs<br />

8.8 Using Set and Get Methods<br />

8.8.1 Executing an Applet that Uses <strong>Program</strong>mer-Defined<br />

Packages<br />

8.9 Software Reusability<br />

8.10 Final Instance Variables<br />

8.11 Composition: Objects as Instance Variables of Other Classes<br />

8.12 Package Access<br />

8.13 Using the this Reference<br />

8.14 Finalizers<br />

8.15 Static Class Members<br />

8.16 Data Abstraction and Encapsulation<br />

8.16.1 Example: Queue Abstract Data Type<br />

8.17 (Optional Case Study) Thinking About Objects: Starting <strong>to</strong> <strong>Program</strong><br />

the Classes for the Eleva<strong>to</strong>r Simulation<br />

Summary • Terminology • Self-Review Exercises • Answers <strong>to</strong> Self-Review Exercises • Exercises<br />

8.1 Introduction<br />

Now we investigate object orientation in <strong>Java</strong> in greater depth. Why did we defer this until<br />

now? First, the objects we will build will be composed in part of structured program pieces,<br />

so we needed <strong>to</strong> establish a basis in structured programming with control structures. Second,<br />

we wanted <strong>to</strong> study methods in depth. Third, we wanted <strong>to</strong> familiarize the reader with<br />

arrays that are <strong>Java</strong> objects.<br />

Through our discussions of object-oriented <strong>Java</strong> programs in Chapter 2 through<br />

Chapter 7, we introduced many basic concepts (i.e., “object think”) and terminology (i.e.,<br />

“object speak”) of object-oriented programming in <strong>Java</strong>. We also discussed our programdevelopment<br />

methodology: We analyzed many typical problems that required a program—either<br />

a <strong>Java</strong> applet or a <strong>Java</strong> application—<strong>to</strong> be built, determined what classes<br />

from the <strong>Java</strong> API were needed <strong>to</strong> implement the program, determined what instance variables<br />

were needed, determined what methods were needed and specified how an object of<br />

our class collaborated with objects of <strong>Java</strong> API classes <strong>to</strong> accomplish the overall goals of<br />

the program.<br />

© Copyright 1992–2002 by Deitel & Associates, Inc. All Rights Reserved. 7/3/01

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!