100% found this document useful (1 vote)
10 views

Instant ebooks textbook Java programming from problem analysis to program design 5th ed Edition D S Malik download all chapters

The document provides information about the 5th edition of 'Java Programming: From Problem Analysis to Program Design' by D.S. Malik, including download links and additional resources for various programming ebooks. It outlines the contents of the textbook, which covers fundamental concepts of Java programming, object-oriented design, and various programming methodologies. The document also mentions electronic rights restrictions and the publisher's policies regarding content usage.

Uploaded by

khomsfokwen
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
10 views

Instant ebooks textbook Java programming from problem analysis to program design 5th ed Edition D S Malik download all chapters

The document provides information about the 5th edition of 'Java Programming: From Problem Analysis to Program Design' by D.S. Malik, including download links and additional resources for various programming ebooks. It outlines the contents of the textbook, which covers fundamental concepts of Java programming, object-oriented design, and various programming methodologies. The document also mentions electronic rights restrictions and the publisher's policies regarding content usage.

Uploaded by

khomsfokwen
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 67

Visit https://ebookfinal.

com to download the full version and


explore more ebooks

Java programming from problem analysis to


program design 5th ed Edition D S Malik

_____ Click the link below to download _____


https://ebookfinal.com/download/java-programming-from-
problem-analysis-to-program-design-5th-ed-edition-d-s-
malik/

Explore and download more ebooks at ebookfinal.com


Here are some suggested products you might be interested in.
Click the link to download

C Programming Program Design Including Data Structures 5th


Edition D. S. Malik

https://ebookfinal.com/download/c-programming-program-design-
including-data-structures-5th-edition-d-s-malik/

Java An Introduction to Problem Solving and Programming


7th Edition Walter Savitch

https://ebookfinal.com/download/java-an-introduction-to-problem-
solving-and-programming-7th-edition-walter-savitch/

Simply Java An Introduction to Java Programming


Programming Series 1st Edition James Levenick

https://ebookfinal.com/download/simply-java-an-introduction-to-java-
programming-programming-series-1st-edition-james-levenick/

Professional Java Programming JDK 5 5th Edition W. Clay


Richardson

https://ebookfinal.com/download/professional-java-programming-
jdk-5-5th-edition-w-clay-richardson/
Java How to Program 7th Edition Harvey M. Deitel

https://ebookfinal.com/download/java-how-to-program-7th-edition-
harvey-m-deitel/

Java How to Program 4th Edition Harvey M. Deitel

https://ebookfinal.com/download/java-how-to-program-4th-edition-
harvey-m-deitel/

ASP NET Website Programming Problem Design Solution C


Edition Marco Bellinaso

https://ebookfinal.com/download/asp-net-website-programming-problem-
design-solution-c-edition-marco-bellinaso/

Java ME game programming 2nd ed Edition John P Flynt

https://ebookfinal.com/download/java-me-game-programming-2nd-ed-
edition-john-p-flynt/

Mastering AspectJ Aspect Oriented Programming in Java 1st


Edition Joseph D. Gradecki

https://ebookfinal.com/download/mastering-aspectj-aspect-oriented-
programming-in-java-1st-edition-joseph-d-gradecki/
Java programming from problem analysis to program
design 5th ed Edition D S Malik Digital Instant Download
Author(s): D S Malik
ISBN(s): 9781111577643, 1111577641
Edition: 5th ed
File Details: PDF, 7.00 MB
Year: 2012
Language: english
This is an electronic version of the print textbook. Due to electronic rights restrictions,
some third party content may be suppressed. Editorial review has deemed that any suppressed
content does not materially affect the overall learning experience. The publisher reserves the right
to remove content from this title at any time if subsequent rights restrictions require it. For
valuable information on pricing, previous editions, changes to current editions, and alternate
formats, please visit www.cengage.com/highered to search by ISBN#, author, title, or keyword for
materials in your areas of interest.
1019763_FM_VOL-I.qxp 9/17/07 4:22 PM Page viii

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
S 50
R 51

1st Pass Pages


Java Programming: From Problem Analysis ª 2012 Course Technology, Cengage Learning
to Program Design, Fifth Edition
ALL RIGHTS RESERVED. No part of this work covered by the
D.S. Malik copyright herein may be reproduced, transmitted, stored or used
Executive Editor: Marie Lee in any form or by any means graphic, electronic, or mechanical,
including but not limited to photocopying, recording, scanning,
Acquisitions Editor: Brandi Shailer digitizing, taping, Web distribution, information networks, or
Senior Product Manager: Alyssa Pratt information storage and retrieval systems, except as permitted
Editorial Assistant: Jacqueline Lacaire under Section 107 or 108 of the 1976 United States Copyright Act,
without the prior written permission of the publisher.
Content Project Manager: Lisa Weidenfeld
Associate Marketing Manager: Shanna For product information and technology assistance, contact us at
Shelton Cengage Learning Customer & Sales Support, 1-800-354-9706
Art Director: Faith Brosnan For permission to use material from this text or product, submit
all requests online at www.cengage.com/permissions
Proofreader: Andrea Schein
Further permissions questions can be emailed to
Indexer: Alexandra Nickerson permissionrequest@cengage.com
Print Buyer: Julio Esperas
Cover Designer: Roycroft Design/
www.roycroftdesign.com Library of Congress Control Number: 2010940363
Cover Photo: ª photolibrary/Richard ISBN-13: 978-1-111-53053-2
Cummins ISBN-10: 1-111-53053-x
Compositor: Integra Course Technology
20 Channel Center Street
Boston, MA 02210
Some of the product names and company
USA
names used in this book have been used for
identification purposes only and may be
trademarks or registered trademarks of their Cengage Learning is a leading provider of customized
respective manufacturers and sellers. learning solutions with office locations around the globe,
including Singapore, the United Kingdom, Australia, Mexico,
Any fictional data related to persons or
Brazil and Japan. Locate your local office at:
companies or URLs used throughout this
www.cengage.com/global
book is intended for instructional purposes
only. At the time this book was printed, any Cengage Learning products are represented in Canada by
such data was fictional and not belonging to Nelson Education, Ltd.
any real persons or companies.
To learn more about Course Technology, visit
Course Technology, a part of Cengage www.cengage.com/coursetechnology
Learning, reserves the right to revise this
Purchase any of our products at your local college store
publication and make changes from time to
or at our preferred online store www.cengagebrain.com
time in its content without notice.
The programs in this book are for
instructional purposes only. They have been
tested with care, but are not guaranteed for
any particular intent beyond educational
purposes. The author and the publisher do
not offer any warranties or representations,
nor do they accept any liabilities with respect
to the programs.

Printed in the United States of America


1 2 3 4 5 6 7 16 15 14 13 12 11 10
JAVA PROGRAMMING
FROM PROBLEM ANALYSIS TO PROGRAM DESIGN

FIFTH EDITION

D.S. MALIK

Australia  Brazil  Japan  Korea  Mexico  Singapore  Spain  United Kingdom  United States
TO

My Daughter

Shelly Malik
B RIEF C ONTENTS

PREFACE xix
1. An Overview of Computers and Programming Languages 1

2. Basic Elements of Java 25

3. Introduction to Objects and Input/Output 113

4. Control Structures I: Selection 177

5. Control Structures II: Repetition 249

6. Graphical User Interface (GUI) and Object-Oriented Design (OOD) 327

7. User-Defined Methods 383

8. User-Defined Classes and ADTs 465

9. Arrays 551

10. Inheritance and Polymorphism 639

11. Handling Exceptions and Events 723

12. Advanced GUIs and Graphics 783

13. Recursion 873

14. Searching and Sorting 907

APPENDIX A Java Reserved Words 939

APPENDIX B Operator Precedence 941

APPENDIX C Character Sets 945

APPENDIX D Additional Java Topics 949

APPENDIX E Answers to Odd-Numbered Exercises 997

INDEX 1023
TABLE OF C ONTENTS

Preface xix

AN OVERVIEW OF COMPUTERS AND


1 PROGRAMMING LANGUAGES 1
Introduction 2

An Overview of the History of Computers 2

Elements of a Computer System 4


Hardware 4
Software 6

Language of a Computer 6

Evolution of Programming Languages 8

Processing a Java Program 10

Internet, World Wide Web, Browser, and Java 13

Programming with the Problem


Analysis–Coding–Execution Cycle 13

Programming Methodologies 19
Structured Programming 19
Object-Oriented Programming 19

Quick Review 21

Exercises 23
Table of Contents | vii

BASIC ELEMENTS OF JAVA 25


2 A Java Program 26

Basics of a Java Program 28


Comments 29
Special Symbols 30
Reserved Words (Keywords) 30
Identifiers 31

Data Types 32
Primitive Data Types 32

Arithmetic Operators and Operator Precedence 36


Order of Precedence 39

Expressions 40
Mixed Expressions 41

Type Conversion (Casting) 43

class String 45
Strings and the Operator + 46

Input 48
Allocating Memory with Named Constants and Variables 48
Putting Data into Variables 51
Declaring and Initializing Variables 55
Input (Read) Statement 56
Reading a Single Character 61

Increment and Decrement Operators 64

Output 66

Packages, Classes, Methods, and the import Statement 71

Creating a Java Application Program 72

Debugging: Understanding and Fixing Syntax Errors 77

Programming Style and Form 80


Syntax 80

Avoiding Bugs: Consistent, Proper Formatting and


Code Walk-Through 84
viii | Java Programming: From Problem Analysis to Program Design, Fifth Edition

More on Assignment Statements (Optional) 85

Quick Review 94

Exercises 97

Programming Exercises 106

INTRODUCTION TO OBJECTS AND INPUT/OUTPUT 113


3 Objects and Reference Variables 114

Using Predefined Classes and Methods in a Program 118


Dot Between Class (Object) Name and Class Member: A
Precaution 120

class String 121

Input/Output 129
Formatting Output with printf 129
Using Dialog Boxes for Input/Output 139
Formatting the Output Using the String Method format 146

File Input/Output 149


Storing (Writing) Output to a File 152

Debugging: Understanding Logic Errors and


Debugging with print or println Statements 163

Quick Review 165

Exercises 167

Programming Exercises 171

CONTROL STRUCTURES I: SELECTION 177


4 Control Structures 178

Relational Operators 180

Relational Operators and Primitive Data Types 181

Logical (Boolean) Operators and Logical Expressions 183

Order of Precedence 185


boolean Data Type and Logical (Boolean) Expressions 189
Table of Contents | ix

Selection: if and if...else 190


One-Way Selection 190
Two-Way Selection 193
Compound (Block of) Statements 197
Multiple Selections: Nested if 198
Comparing if...else Statements with a Series
of if Statements 200
Short-Circuit Evaluation 201
Comparing Floating-Point Numbers for Equality:
A Precaution 202
Conditional Operator (? :) (Optional) 204

Avoiding Bugs by Avoiding Partially Understood


Concepts and Techniques 204

Program Style and Form (Revisited): Indentation 208

switch Structures 208

Avoiding Bugs by Avoiding Partially Understood


Concepts and Techniques (Revisited) 215

Comparing Strings 223


Strings, the Assignment Operator, and the Operator new 229

Quick Review 230

Exercises 232

Programming Exercises 241

CONTROL STRUCTURES II: REPETITION 249


5 Why Is Repetition Needed? 250

while Looping (Repetition) Structure 251


Designing while Loops 254
Counter-Controlled while Loops 255
Sentinel-Controlled while Loops 257
Flag-Controlled while Loops 263
EOF-Controlled while Loops 266
More on Expressions in while Statements 271

for Looping (Repetition) Structure 278


x | Java Programming: From Problem Analysis to Program Design, Fifth Edition

do...while Looping (Repetition) Structure 288


Choosing the Right Looping Structure 293

break and continue Statements 293

Avoiding Bugs by Avoiding Patches 295

Debugging Loops 298

Nested Control Structures 299

Quick Review 304

Exercises 306

Programming Exercises 319

GRAPHICAL USER INTERFACE (GUI) AND


6 OBJECT-ORIENTED DESIGN (OOD) 327
Graphical User Interface (GUI) Components 328
Creating a Window 332
JFrame 332
Getting Access to the Content Pane 338
JLabel 339
JTextField 343
JButton 347

Object-Oriented Design 363


A Simplified OOD Methodology 364

Implementing Classes and Operations 370


Primitive Data Types and the Wrapper Classes 370

Quick Review 377

Exercises 378

Programming Exercises 381

USER-DEFINED METHODS 383


7 Predefined Methods 384
Using Predefined Methods in a Program 388

User-Defined Methods 391


Value-Returning Methods 391
Table of Contents | xi

return Statement 395


Final Program 398

Flow of Execution 404

Void Methods 407

Primitive Data Type Variables as Parameters 411

Reference Variables as Parameters 414


Parameters and Memory Allocation 414
Reference Variables of the String Type as Parameters:
A Precaution 414
The class StringBuffer 418

Primitive Type Wrapper Classes as Parameters 421

Scope of an Identifier Within a Class 422

Method Overloading: An Introduction 427

Debugging: Using Drivers and Stubs 440

Avoiding Bugs: One-Piece-at-a-Time Coding 442

Quick Review 442

Exercises 445

Programming Exercises 456

USER-DEFINED CLASSES AND ADTS 465


8 Classes and Objects 466
Constructors 471
Unified Modeling Language Class Diagrams 472
Variable Declaration and Object Instantiation 473
Accessing Class Members 475
Built-in Operations on Classes 476
Assignment Operator and Classes: A Precaution 476
Class Scope 478
xii | Java Programming: From Problem Analysis to Program Design, Fifth Edition

Methods and Classes 479


Definitions of the Constructors and Methods
of the class Clock 479

Classes and the Method toString 494

Copy Constructor 500

Static Members of a Class 501


static Variables (Data Members) of a Class 503

Finalizers 507

Accessor and Mutator Methods 507

Debugging—Designing and Documenting a Class 510

Reference this (Optional) 512


Cascaded Method Calls (Optional) 514

Inner Classes 517

Abstract Data Types 517

Quick Review 537

Exercises 538

Programming Exercises 547

ARRAYS 551
9 Why Do We Need Arrays? 552

Arrays 553
Alternate Ways to Declare an Array 555
Accessing Array Elements 555
Specifying Array Size during Program Execution 557
Array Initialization during Declaration 558
Arrays and the Instance Variable length 558
Processing One-Dimensional Arrays 559
Array Index Out of Bounds Exception 564
Declaring Arrays as Formal Parameters to Methods 564
Assignment Operator, Relational Operators, and Arrays:
A Precaution 565
Arrays as Parameters to Methods 567
Table of Contents | xiii

Searching an Array for a Specific Item 572

Arrays of Objects 574


Arrays of string Objects 574
Arrays of Objects of Other Classes 576

Arrays and Variable Length Parameter List (Optional) 581

Two-Dimensional Arrays 589


Accessing Array Elements 591
Two-Dimensional Array Initialization during Declaration 594
Processing Two-Dimensional Arrays 595
Passing Two-Dimensional Arrays as Parameters to Methods 599

Multidimensional Arrays 603

class Vector (Optional) 616


Primitive Data Types and the class Vector 620
Vector Objects and the foreach Loop 620

Quick Review 621

Exercises 623

Programming Exercises 634

INHERITANCE AND POLYMORPHISM 639


10 Inheritance 640
Using Methods of the Superclass in a Subclass 642
Constructors of the Superclass and Subclass 648
Protected Members of a Class 657
Protected Access vs Package Access 660

class Object 661

Java Stream Classes 663

Polymorphism 664
Operator instanceof 670

Abstract Methods and Classes 674

Interfaces 681
xiv | Java Programming: From Problem Analysis to Program Design, Fifth Edition

Polymorphism Via Interfaces 682

Composition (Aggregation) 684

Quick Review 709

Exercises 712

Programming Exercises 719

HANDLING EXCEPTIONS AND EVENTS 723


11 Handling Exceptions Within a Program 724
Java’s Mechanism of Exception Handling 727
try/catch/finally Block 728

Java Exception Hierarchy 733

Java’s Exception Classes 736

Checked and Unchecked Exceptions 741

More Examples of Exception Handling 743


class Exception and the Operator instanceof 746

Rethrowing and Throwing an Exception 749

Method printStackTrace 753

Exception-Handling Techniques 755


Terminate the Program 755
Fix the Error and Continue 756
Log the Error and Continue 757

Creating Your Own Exception Classes 758

Event Handling 760

Quick Review 775

Exercises 777

Programming Exercises 781


Table of Contents | xv

ADVANCED GUIS AND GRAPHICS 783


12 Applets 787

class Font 791

class Color 794

class Graphics 800


Converting an Application Program to an Applet 808

Additional GUI Components 811


JTextArea 811
JCheckBox 816
JRadioButton 823
JComboBox 828
JList 833

Layout Managers 839


FlowLayout 840
BorderLayout 843

Menus 844

Key and Mouse Events 847


Key Events 848
Mouse Events 850

Quick Review 865

Exercises 866

Programming Exercises 868

RECURSION 873
13
Recursive Definitions 874
Direct and Indirect Recursion 876
Infinite Recursion 877
Designing Recursive Methods 877

Problem Solving Using Recursion 878


Tower of Hanoi: Analysis 887

Recursion or Iteration? 888


xvi | Java Programming: From Problem Analysis to Program Design, Fifth Edition

Quick Review 896

Exercises 897

Programming Exercises 901

SEARCHING AND SORTING 907


14
List Processing 908
Searching 908
Selection Sort 909
Insertion Sort 913
Binary Search 917

Quick Review 934

Exercises 934

Programming Exercises 936

APPENDIX A: JAVA RESERVED WORDS 939

APPENDIX B: OPERATOR PRECEDENCE 941

APPENDIX C: CHARACTER SETS 945


ASCII (American Standard Code for Information
Interchange), the First 128 Characters of the
Unicode Character Set 945
EBCDIC (Extended Binary Coded Decimal
Interchange Code) 946

APPENDIX D: ADDITIONAL JAVA TOPICS 949


Binary (Base 2) Representation of a Nonnegative Integer 949
Converting a Base 10 Number to a Binary Number (Base 2) 949
Converting a Binary Number (Base 2) to Base 10 951
Converting a Binary Number (Base 2) to Octol (Base 8)
and Hexdecimal (Base 16) 952
Table of Contents | xvii

Executing Java Programs Using the Command-Line


Statements 954
Setting the Path in Windows 7.0 (Professional) 954
Executing Java Programs 959
Java Style Documentation 964

Creating Your Own Packages 966


Multiple File Programs 969

Formatting the Output of Decimal Numbers Using


the class DecimalFormat 969

Packages and User-Defined Classes 972


Primitive Type Classes 972
Class: IntClass 972
Class: LongClass 976
Class: CharClass 977
Class: FloatClass 977
Class: DoubleClass 978
Class: BooleanClass 979
Using Primitive Type Classes in a Program 980

Enumeration Types 981

APPENDIX E: ANSWERS TO ODD-NUMBERED


EXERCISES 997
Chapter 1 997

Chapter 2 998

Chapter 3 1001

Chapter 4 1002

Chapter 5 1004

Chapter 6 1007

Chapter 7 1008

Chapter 8 1010

Chapter 9 1014
xviii | Java Programming: From Problem Analysis to Program Design, Fifth Edition

Chapter 10 1016

Chapter 11 1018

Chapter 12 1019

Chapter 13 1020

Chapter 14 1020

INDEX 1023
P REFACE TO THE F IFTH
E DITION

Welcome to Java Programming: From Problem Analysis to Program Design, Fifth Edition.
Designed for a first Computer Science (CS1) Java course, this text will provide a breath of
fresh air to you and your students. The CS1 course serves as the cornerstone of the Computer
Science curriculum. My primary goal is to motivate and excite all programming students,
regardless of their level. Motivation breeds excitement for learning. Motivation and excite-
ment are critical factors that lead to the success of the programming student. This text is the
culmination and development of my classroom notes throughout more than fifty semesters of
teaching successful programming.
Warning: This text can be expected to create a serious reduction in the demand for program-
ming help during your office hours. Other side effects include significantly diminished student
dependency on others while learning to program.

The primary focus in writing this text is on student learning. Therefore, in addition to clear
explanations, we address the key issues that otherwise impede student learning. For example, a
common question that arises naturally during an early programming assignment is: ‘‘How
many variables and what kinds are needed in this program?’’ We illustrate this important and
crucial step by helping students learn why variables are needed and how data in a variable is
manipulated. Next students learn that the analysis of the problem will spill the number and
types of the variables. Once students grasp this key concept, control structures (selection and
loops) become easier to learn. The second major impediment in learning programming is
parameter passing. We pay special attention to this topic. First students learn how to use
predefined methods and how actual and formal parameters relate. Next students learn about
user-defined methods. They see visual diagrams that help them learn how methods are called
and how formal parameters affect actual parameters. Once students have a clear understanding
of these two key concepts, they readily assimilate advanced topics.
The topics are introduced at a pace that is conducive to learning. The writing style is friendly,
engaging, and straightforward. It parallels the learning style of the contemporary CS1 student.
Before introducing a key concept, the student learns why the concept is needed, and then sees
examples illustrating the concept. Special attention is paid to topics that are essential in
mastering the Java programming language and in acquiring a foundation for further study
of computer science.
xx | Java Programming: From Problem Analysis to Program Design, Fifth Edition

Other important topics include debugging techniques and techniques for avoiding programming
bugs. When a beginner compiles his/her first program and sees that the number of errors exceeds the
length of this first program, he/she becomes frustrated by the plethora of errors, only some of which
can be interpreted. To ease this frustration and help students learn to produce correct programs,
debugging and bug avoidance techniques are presented systematically throughout the text.

Changes in the Fifth Edition


The main changes are:
• In the fifth edition, new debugging sections have been added and some of the old
ones have been rewritten. These sections are indicated with a debugging icon.
• The fifth edition contains more than 125 new exercises, 27 new programming
exercises, and numerous new examples spread throughout the book.
• In Chapters 6 and 12 the GUI figures have been captured and replaced in Windows 7
Professional environment.
• Appendix D contains screen images illustrating how to compile and execute a Java
program using the command-line statements as well as how to set the path in
Windows 7 Professional environment.
These changes were implemented based on comments from the text reviewers of the fifth
edition. The source code and the programming exercises are developed and tested using Java
6.0 and the version of Java 7.0 available at the time this book was being typeset.

Approach
Once conceived as a Web programming language, Java slowly but surely found its way into
classrooms where it now serves as a first programming language in computer science curricula
(CS1). Java is a combination of traditional style programming—programming with a non-
graphical user interface—and modern style programming with a graphical user interface
(GUI). This book introduces you to both styles of programming. After giving a brief
description of each chapter, we discuss how to read this book.
Chapter 1 briefly reviews the history of computers and programming languages. The reader
can quickly skim and become familiar with some of the hardware and software components of
the computer. This chapter also gives an example of a Java program and describes how a Java
program is processed. The two basic problem-solving techniques, structured programming
and object-oriented design, are also presented.
After completing Chapter 2, students become familiar with the basics of Java and are ready to
write programs that are complicated enough to do some computations. The debugging section
in this chapter illustrates how to interpret and correct syntax errors.
The three terms that you will encounter throughout the book are—primitive type variables,
reference variables, and objects. Chapter 3 makes clear distinctions between these terms and
sets the tone for the rest of the book. An object is a fundamental entity in an object-oriented
Preface to the Fifth Edition | xxi

programming language. This chapter further explains how an object works. The class
String is one of the most important classes in Java. This chapter introduces this class and
explains how various methods of this class can be used to manipulate strings. Because input/
output is fundamental to any programming language, it is introduced early, and is covered in
detail in Chapter 3. The debugging section in this chapter illustrates how to find and correct
logical errors.
Chapters 4 and 5 introduce control structures used to alter the sequential flow of execution.
The debugging sections in these chapters discuss and illustrate logical errors associated with
selection and looping structures.
Java is equipped with powerful yet easy-to-use graphical user interface (GUI) components
to create user-friendly graphical programs. Chapter 6 introduces various GUI components
and gives examples of how to use these components in Java application programs. Because
Java is an object-oriented programming language, the second part of Chapter 6 discusses
and gives examples of how to solve various problems using object-oriented design
methodology.
Chapter 7 discusses user-defined methods. Parameter passing is a fundamental concept in any
programming language. Several examples, including visual diagrams, help readers understand
this concept. It is recommended that readers with no prior programming background spend
extra time on this concept. The debugging section in this chapter discuss how to debug a
program using stubs and drivers.
Chapter 8 discusses user-defined classes. In Java, a class is an important and widely used
element. It is used to create Java programs, group related operations, and it allows users to
create their own data types. This chapter uses extensive visual diagrams to illustrate how
objects of classes manipulate data.
Chapter 9 describes arrays. This chapter also introduces variable length formal parameter lists.
In addition, this chapter introduces foreach loops and explains how this loop can be used to
process the elements of an array. This chapter also discusses the sequential searching algorithm
and the class Vector.
Inheritance is an important principle of object-oriented design. It encourages code reuse.
Chapter 10 discusses inheritance and gives various examples to illustrate how classes are
derived from existing classes. In addition, this chapter also discusses polymorphism, abstract
classes, inner classes, and composition.
An occurrence of an undesirable situation that can be detected during program execution is
called an exception. For example, division by zero is an exception. Java provides extensive
support for handing exceptions. Chapter 11 shows how to handle exceptions in a program.
Chapter 11 also discusses event handling, which was introduced in Chapter 6. Chapter 12
picks up the discussion of GUI components started in Chapter 6. This chapter introduces
additional GUI components and discusses how to create applets.
Chapter 13 introduces recursion. Several examples illustrate how recursive methods
execute.
xxii | Java Programming: From Problem Analysis to Program Design, Fifth Edition

Chapter 14 discusses a binary search algorithm as well as bubble sort, selection sort, insertion
sort, and quick sort algorithms. Additional content covering the sorting algorithms bubble sort
and quick sort is provided online at www.cengagebrain.com.
Appendix A lists the reserved words in Java. Appendix B shows the precedence and
associativity of the Java operators. Appendix C lists the ASCII (American Standard Code
for Information Interchange) portion of the Unicode character set as well as the EBCDIC
(Extended Binary Code Decimal Interchange) character set.
Appendix D contains additional topics in Java. The topics covered are converting a base 10
number to binary (base 2) number and vice versa, converting a number from base 2 to base 8 (base
16) and vice versa, how to compile and execute a Java program using command line statements,
how to create Java style documentation of the user-defined classes, how to create packages, how to
use user-defined classes in a Java program, and enum type. Appendix E gives answers to the odd-
numbered exercises in the text. Those odd-numbered exercises with very long solutions will not
be in the text, but will be provided to students online at www.cengagebrain.com.

How To Use This Book


Java is a complex and very powerful language. In addition to traditional (non-GUI) program-
ming, Java provides extensive support for creating programs that use a graphical user interface
(GUI). Chapter 3 introduces graphical input and output dialog boxes. Chapter 6 introduces
the most commonly used GUI components such as labels, buttons, and text fields. More
extensive coverage of GUI components is provided in Chapter 12.
This book can be used in two ways. One way is an integrated approach in which readers learn
how to write both non-GUI and GUI programs as they learn basic programming concepts
and skills. The other approach focuses on illustrating fundamental programming concepts
with non-GUI programming first, and later incorporating GUI components. The recom-
mended chapter sequence for each of these approaches is as follows:
• Integrated approach: Study all chapters in sequence.
• Non-GUI first, then GUI: Study Chapters 1–5 in sequence. Then study Chapters
7–11 and Chapters 13 and 14. This approach initially skips Chapters 6 and 12, the
primary GUI chapters. After studying Chapters 1–5, 7–11, 13, and 14, the reader can
come back to study Chapters 6 and 12, the GUI chapters. Also note that Chapter 14
can be studied after Chapter 9.
If you choose the second approach, it should also be noted that the Programming Examples in
Chapters 8 and 10 are developed first without any GUI components, and then the programs
are extended to incorporate GUI components. Also, if Chapter 6 is skipped, the reader can skip
the event handling part of Chapter 11. Chapter 13 (recursion) contains two Programming
Examples: one creates a non-GUI application program, while the other creates a program that
uses GUI. If you skip Chapters 6 and 12, you can skip the GUI part of the Programming
Examples in Chapters 8, 10, 11, and 13. Once you have studied Chapter 6 and 12, you can
study the GUI part of the Programming Examples of Chapters 8, 10, 11, and 13.
Preface to the Fifth Edition | xxiii

Figure 1 shows a chapter dependency diagram for this book. Solid arrows indicate that the
chapter at the beginning of the arrow is required before studying the chapter at the end of the
arrow. A dotted arrow indicates that the chapter at the beginning of the arrow is not essential
to studying the chapter at the end of the dotted arrow.

Chapter 1

Chapter 2

Chapter 3

Chapter 4

Chapter 5

Chapter 6 Chapter 7

Chapter 8 Chapter 9

Chapter 10 Chapter 14

Chapter 11

Chapter 12

Chapter 13

A dotted arrow means that the chapter is not essential to studying the following chapter.

FIGURE 1 Chapter dependency diagram

All source code and solutions have been written, compiled, and quality assurance tested
with Java 6.0 and the version of Java 7.0 available at the time this book was being typeset.
FEATURES OF THE BOOK

Four-color
interior design
shows
accurate code
and related
comments.
The debugging
sections show
how to find
and correct
syntax and
semantic
(logical)
errors.
More than
250 visual
diagrams,
both
extensive and
exhaustive,
illustrate difficult
concepts.
Numbered Examples
illustrate the key
concepts with their
relevant code. The
programming code in
these examples is
followed by a Sample
Run. An explanation
then follows that
describes what each
line in the code does.
Notes highlight
important facts
about the concepts
introduced in the
chapter.
Programming
Examples are
complete programs
featured in each
chapter. These
examples include the
accurate, concrete
stages of Input,
Output, Problem
Analysis and Algorithm
Design, and a
Complete Program
Listing.
Exercises further
reinforce learning
and ensure that
students have, in
fact, mastered the
material.
Programming
Exercises challenge
students to write
Java programs with
a specified
outcome.
S UPPLEMENTAL
R ESOURCES

The following supplemental materials are available when this book is used in a classroom setting.
Most instructor teaching tools, outlined below, are available with this book on a single
CD-ROM, and are also available for instructor access at login.cengage.com.

Electronic Instructor’s Manual


The Instructor’s Manual that accompanies this textbook includes:
• Additional instructional material to assist in class preparation, including suggestions
for lecture topics.
• Solutions to all the end-of-chapter materials, including the Programming Exercises.

ExamViewÒ
This textbook is accompanied by ExamView, a powerful testing software package that allows
instructors to create and administer printed, computer (LAN-based), and Internet exams.
ExamView includes hundreds of questions that correspond to the topics covered in this text,
enabling students to generate detailed study guides that include page references for further
review. These computer-based and Internet testing components allow students to take exams
at their computers, and save the instructor time because each exam is graded automatically.

PowerPoint Presentations
Microsoft PowerPoint slides are available for each chapter. These slides are provided as a teaching
aid for classroom presentations, either to make available to students on the network for chapter
review, or to be printed for classroom distribution. Instructors can add their own slides for
additional topics that they introduce to the class.

Distance Learning
Course Technology is proud to present online courses in WebCT and Blackboard to provide
the most complete and dynamic learning experience possible. For more information on how
xxxiv | Java Programming: From Problem Analysis to Program Design, Fifth Edition

to bring distance learning to your course, contact your local Course Technology sales
representative.

Source Code
The source code is available for students at www.cengagebrain.com. At the cengagebrain.com home
page, search for the ISBN of your title (from the back cover of your book) using the search
box at the top of the page. This will take you to the product page where these resources can
be found. The source code is also available on the Instructor Resources CD-ROM. The
input files needed to run some of the programs are also included with the source code.

Additional Student Files


The Additional Student Files referenced throughout the text are available on the Instructor
Resources CD. Students can download these files directly at www.cengagebrain.com. At the
cengagebrain.com home page, search for the ISBN of your title using the search box at the top
of the page. This will take you to the product page where these resources can be found. Click
the Access Now link below the book cover to find all study tools and additional files available
directly to students. Additional Student Files appear on the left navigation and provide access
to additional Java programs, selected solutions, and more.

Solution Files
The solution files for all programming exercises are available for instructor download at
http://login.cengage.com and are also available on the Instructor Resources CD-ROM. The
input files needed to run some of the programming exercises are also included with the
solution files.
A CKNOWLEDGMENTS

There are many people I must thank who, in one way or another, contributed to the success
of this book. First, I would like to thank those who e-mailed numerous comments that helped
to improve on the fourth edition. I am thankful to Professors S.C. Cheng and Randall Crist
for constantly supporting this project.
I owe a great deal to the following reviewers, who patiently read each page of every chapter
of the current version and made critical comments that helped to improve the book:
Nadimpalli Mahadev, Fitchburg State College and Baoqiang Yan, Missouri Western State
University. Additionally, I would like to thank Brian Candido, Springfield Technical Com-
munity College, for his review of the proposal package. The reviewers will recognize that
their suggestions have not been overlooked and, in fact, made this a better book.
Next, I express thanks to Brandi Shailer, Acquisitions Editor, for recognizing the importance
and uniqueness of this project. All this would not have been possible without the careful
planning of Senior Product Manager Alyssa Pratt. I extend my sincere thanks to Alyssa, as well
as to Content Project Manager, Lisa Weidenfeld. I also thank Sreejith Govindan of Integra
Software Services for assisting us in keeping the project on schedule. I would like to thank
Chris Scriver and Serge Palladino of the MQA department of Course Technology for patiently
and carefully proofreading the text, testing the code, and discovering typos and errors.
I am thankful to my parents for their blessings.
Finally, I am thankful to the support of my wife Sadhana, and especially my daughter Shelly,
to whom this book is dedicated. They cheered me up whenever I was overwhelmed during
the writing of this book.
We welcome any comments concerning the text. Comments may be forwarded to the
following e-mail address: malik@creighton.edu.
D.S. Malik
1
CHAPTER

A N O VERVIEW OF
COMPUTERS AND
P ROGRAMMING
L ANGUAGES
I N T H I S C H A P T E R , YO U W I L L :
. Learn about different types of computers
. Explore the hardware and software components of a computer system
. Learn about the language of a computer
. Learn about the evolution of programming languages
. Examine high-level programming languages
. Discover what a compiler is and what it does
. Examine how a Java program is processed
. Learn about the Internet and World Wide Web
. Learn what an algorithm is and explore problem-solving techniques
. Become familiar with structured and object-oriented programming design methodologies
2 | Chapter 1: An Overview of Computers and Programming Languages

Introduction
Terms such as ‘‘the Internet,’’ which was unfamiliar just a few years ago, are now
common. Elementary school students regularly ‘‘surf’’ the Internet and use computers
to design their classroom projects. Many people use the Internet to look up information
and to communicate with others. These Internet activities are all made possible by the
availability of different software, also known as computer programs. Software is devel-
oped by using programming languages. The Java programming language is especially well
suited for developing software to accomplish specific tasks. Our main objective is to teach
you how to write programs in the Java programming language. Before you begin
programming, it is useful if you understand some of the basic terminology and different
components of a computer. We begin with an overview of the history of computers.

An Overview of the History of Computers


The first device known to carry out calculations was the abacus. The abacus was invented
in Asia but was used in ancient Babylon, China, and throughout Europe until the late
middle ages. The abacus uses a system of sliding beads on a rack for addition and
subtraction. In 1642, the French philosopher and mathematician Blaise Pascal invented
the calculating device called the Pascaline. It had eight movable dials on wheels that could
calculate sums up to eight figures long. Both the abacus and Pascaline could perform only
addition and subtraction operations. Later in the seventeenth century, Gottfried von
Leibniz invented a device that was able to add, subtract, multiply, and divide. In 1819,
Joseph Jacquard, a French weaver, discovered that the weaving instructions for his looms
could be stored on cards with holes punched in them. While the cards moved throughout the
loom in sequence, needles passed through the holes and picked up threads of the correct color
and texture. A weaver could rearrange the cards and change the pattern being woven. In
essence, the cards programmed a loom to produce patterns in cloth. The weaving industry
seems to have little in common with the computer industry. However, the idea of storing
information by punching holes on a card turned out to be of great importance in the later
development of computers.
In the early and mid-1800s, Charles Babbage, an English mathematician and physical
scientist, designed two calculating machines—the difference engine and the analytical
engine. The difference engine could automatically perform complex operations, such as
squaring numbers. Babbage built a prototype of the difference engine, but did not build
the actual device. The first complete difference engine was completed in London in
2002, 153 years after it was designed. It consists of 8,000 parts, weighs five tons, and
measures 11 feet long. A replica of the difference engine was completed in 2008 and is on
display at the Computer History Museum in Mountain View, California (http://
www.computerhistory.org/babbage/). Most of Babbage’s work is known through the writings
of his colleague Ada Augusta, Countess of Lovelace. Augusta is considered to be the first
computer programmer.
Exploring the Variety of Random
Documents with Different Content
our Abbey, will see that this is so; and besides these, our Abbey held
other lands as well, so that when Sherborne ceased to be the caput
of this fair estate, much that had once come our way ceased to come
hither any more. Though the presence of the school here has in later
times done much to redeem this loss, one cannot say that it has
entirely done so.
The Entrance to Sherborne School.

Of all the ancient institutions in Sherborne, that one which has


kept its dwelling-place longest, which is to-day what it was before
Wessex became one with England, is Sherborne School. The old
Castle is a ruin, the Almshouse dates only from the fifteenth century,
the Abbey Church became the parish church only in 1540. But the
School, though it suffered pecuniary loss in 1539 by the dissolution
of the monastery, suffered no breach of continuity; it was in existence
when the Almshouse was founded, it educated St. Stephen Harding
in the eleventh century, and we have no reason to think that its
existence suffered any break from Ealdhelm’s day till then. A school
with such a history may well call forth some reverence from those
who love Wessex and know something of its history. Our school has
roots which stretch down into the very beginnings of things Christian
among the West Saxons, and there is certainly no existing school in
Wessex that can rival its claim to antiquity.
Sherborne School is fortunate in possessing many ancient
documents illustrative of its history; among these special mention
must be made of a series of accounts commencing in 1553 and
continuing to the present time. Only eleven are missing. Till towards
the end of the eighteenth century they are written on rolls of
parchment, and are for the most part in excellent condition. Besides
these there are a few early court rolls of the school manors at
Bradford Bryan and Barnesby, Lytchett Matravers and Gillingham,
and schedules and leases of its other lands. Among these
documents, too, are records belonging to the old chantries, with the
lands, of which Edward VI. endowed the school; some of these go
back to the reign of Henry VII.
There is no existing minute book of the governors’ proceedings
older than that which begins in 1592; but, luckily, a draft of minutes
exists relating to the years 1549 and 1550, relating, that is to say, to
the time of transition from the old condition of things which obtained
before the dissolution of the monastery, to the new condition created
by the charter granted to the school by Edward VI. The series of
minute books from 1592 onward is complete.
From the school statutes much can be gathered about the
character of the education given in the school. The oldest statutes of
the post-Reformation epoch are lost; they were based, as we learn
from the accounts, on those drawn up by Dean Colet for his school,
once attached to St. Paul’s Cathedral. In 1592, however, a new set
was drawn up for the School of Sherborne by its visitor, Richard
Fletcher, Bishop of Bristol, who, as Dean of Peterborough some
years before, had imposed on him the terrible task of attending
Queen Mary Stuart on the scaffold. Great stress is laid in these
statutes on the “abolishing of the Pope of Rome and all fforrein
powers superiorities and authorities.” From time to time after this
new statutes were made to suit the changing educational and
political views. The statutes all still exist, except those made in 1650
by the Puritans; of these all trace is lost, except the bill for
engrossing them, which amounted to 25s. Statutes were drawn up in
1662 by Gilbert Ironside, Bishop of Bristol, which the Governors
were unwilling to accept, because by these statutes the headmaster
was protected from arbitrary interference on the part of the
Governors. It was not till 1679 that Bishop William Gulston
succeeded in making them accept a new body of statutes, which
contain almost all that Gilbert Ironside proposed, together with some
additional matter. In Bishop Ironside’s draft and Bishop Gulston’s
statutes, it is laid down that it is never lawful “for subjects to take up
armes agt theire Soveraigne upon any pretence wtsoever.” The
language used in and out of school in all official matters was Latin,
and no scholar was to go about the town alone, but with “a
companion one of the Schollars that may be a witness of his
conversation and behaviour under penalty of correction.” The system
of monitorial rule has always been in vogue in the school; in 1592
these rulers are called Impositores—a somewhat awkward term one
must admit; in 1662 and 1679 they are called Prepositores;
nowadays they are called Prefects. In 1679 they were four in
number: “One for discipline in the Schoole, to see all the Schollars
demeane themselves regularly there, the Second for manners both
in the Schoole and abroad any where, the Third for the Churche and
Fields, the Fourth to be Ostiarius, to sitt by the doore, to give
answere to strangers and to keepe the rest from running out.”
When the assizes were held at Sherborne, the judge sat in what is
now the schoolhouse dining-hall—it was then the big schoolroom;
and just before the assizes took place, we get from time to time an
entry of the following kind in the school accounts: “for washinge of ye
King, 6d.” The King referred to is the statue of Edward VI., which still
adorns the room; it is of painted Purbeck marble, and is the work of a
certain Godfrey Arnold; it cost £9 5s. 4d., and was set up in 1614.
The two royal coats of arms, which may still be seen on the south
wall of the old house of the headmaster, and over the south door of
the schoolhouse dining-hall, were taken down by order of a
Commonwealth official in 1650; but they were carefully preserved,
and were restored to their old positions at the Restoration. That on
the old house dates from 1560; that on the dining-hall from 1607.
They used to be bright with tinctures and metals, but since 1670 they
have been “only washed over with oil or some sad colour, without
any more adorning.” The chronogram on the dining-hall is unique, for
it can be made to give two different dates, according to the ways in
which the significant letters are taken. Mr. Hilton, our chief authority
on chronograms, knows of no other which gives two dates in this
fashion. The first date which our chronogram gives is 1550, the date
of the granting of the charter; the second date which it gives is 1670,
that of the rebuilding of the dining-hall.
Among other school buildings of ancient date we must not omit the
library, partly of the thirteenth century, but certainly restored in the
fifteenth; and the school chapel, with its undercroft of the twelfth
century, and its upper story of the fifteenth. The undercroft is a very
precious relic of the past, but the school chapel, which was once the
Abbot’s Hall, has undergone changes and additions; it still keeps its
fine fifteenth century timber roof. The library, on the other hand, has
gone through little change. It was the Guest House of the Monastery,
and has kept its timber roof of the fifteenth century. It is curious that
the windows on the east side of the room are not quite opposite
those on the west side, nor is the divergence uniform; the large
window in the south end of the room is not in the middle of the wall,
but rather towards the west side.
The modern buildings of the school harmonize well with the older
work, for they are all built of the same lovely stone, and the style in
which they are built, though it is in no sense an imitation of this older
work, is yet in harmony with and worthy of it. One of these buildings
deserves more than passing notice, viz., the new big schoolroom,
completed in 1879. The whole group of buildings, with its
surroundings, classrooms, museum, laboratory, drawing school,
music house, Morris tube range, bath and fives courts, deserves
more attention than it usually gets from visitors to Sherborne. These
sojourners often forget that the north side of the exterior of the
church is likely to be as interesting as the south side; if once they
take the trouble to get to this north side, they will be surprised to find
how much fine work, ancient and modern, is to be seen there.
Sherborne Old Castle is situated on an elevated piece of ground to
the east of the town; this ground is about 300 yards long by 150
yards broad; the surface has been made level, and an oval area, 150
yards long by 105 yards broad, has been traced out, and its edges
scarped to a steep slope, with a ditch about 45 feet deep. The
material taken away in forming this scarp and ditch has been thrown
outward, so that the counter scarp is formed of a mound more or
less artificial. It was within this area, above described, that our
Pageant of 1905 was given.
The remains of the Castle are as follows: parts of the curtain wall,
with the gatehouse, the keep, the chapel and hall, along with other
parts of the domestic buildings—all ruinous. The builder of this castle
was Bishop Roger; and William of Malmesbury, who knew it well,
has described the masonry in glowing terms. All that remains is of
this Norman period, though it was somewhat restored and altered in
the fifteenth century. The keep belongs to the class of square keeps.
To judge from two windows of the chapel which still remain in a
fragmentary condition, that building must have been of a very ornate
character. The barrel vaulting of the basement of the keep is worth
study, and a Norman pillar, still standing and supporting a
quadripartite vault, is well known to students of architecture. There is
also a Norman chimney with three flues in the gatehouse.
The ruinous condition of the Castle is not so much due to time as
to gunpowder, for in 1645, after the Castle was taken by Fairfax, it
was blown up by order of the Long Parliament, so as to be no longer
tenable as a fortress. After this, while the troops of the Parliament
occupied Sherborne, their barracks were the school, and their “Court
of Guard” the schoolhouse dining-hall.
This is not the place to deal with the vicissitudes in the tenure of
Sherborne Castle—how the Bishops of Sherborne lost and regained
it. It finally passed from Bishop Henry Cotton into the hands of
Queen Elizabeth in 1599. Sir Walter Ralegh had, however, been
tenant of it since 1592, and when Queen Elizabeth got the fee-
simple of it, she gave it to Ralegh. Ralegh, however, did not care to
live in it; other magnates in this part of the world were building fine
modern houses, and he followed their example. Thus arose the
modern Castle, known in former days as Sherborne Lodge, on the
other side of the lake, the central and loftier part of which is due to
Ralegh. There is no trace of any evidence that Sherborne Castle
was ever besieged before the great Civil War. It was used at times in
the Middle Ages as a prison; for example, in King John’s reign. King
John himself stayed here in 1207 and in 1216.
After some tragic vicissitudes the Sherborne estate came to the
Digbys in 1617, and since this date, with the exception of the
troublous period of the great Civil War, it has remained with them.
Sherborne Castle was twice besieged during the Civil War, first in
1642, and again in 1645. The first siege was uneventful and
unimportant. In 1644 Charles I. had been here after his successful
campaign in the West; Prince Rupert, too, had come, and there had
been great doings with reviews of men in Sherborne Park, after
which followed the second battle of Newbury and the self-denying
ordinance and the creation of the New Model. The second siege,
that of 1645, was more important; not only was Fairfax drawn hither
by it, but Cromwell, too, came as general of cavalry. Though the
Parliamentary troops destroyed much of the old castle that we
should like to see standing now, we must, on the whole, acquit them
of having done any great injury to the buildings of the church or
school.
In 1688, King William III.—then Prince of Orange—on his advance
from Exeter to London, stayed in the modern castle here; his
proclamation to the English people is said to have been printed in
the drawing-room at a printing-press set up on the great hearth-
stone, which was cracked by it.
Let us now turn to the last of our four ancient institutions, viz., the
Almshouse. This institution is certainly older than the year 1437, in
which year, by a license from King Henry VI. to Robert Nevile,
Bishop of Sarum, to Humfrey Stafford, Kt., Margaret Goghe, John
Fauntleroy, and John Baret, it was refounded in honour of St. John
the Baptist and St. John the Evangelist. It is actually older than this,
because some accounts of the charity exist for a few years prior to
this date. Some day, no doubt, the history of the institution will be
more fully worked out than it is at present. Plenty of material exists in
its account rolls which could hardly fail to throw light on old
Sherborne life.
According to the deed of foundation, there were, we are told, to be
twenty brethren, called the Masters of SS. Johns’ House—they are
now called master and brethren—together with a perpetual priest to
pray for the good estate and the souls of the founders and inmates.
The house was to contain twelve poor men and four poor women,
who were to be governed by one of themselves, called the Prior, of
their own election, and a woman of domestic ability was to buy their
food and dress it, wash their clothes and make their beds, who
should be called the Housewife of SS. Johns’ House. The older part
of the building was finished in 1448, and here still stand, not much
altered from what they were then, the chapel, ante-chapel, and
dining-hall, with a long dormitory over the dining-hall; this dormitory
used to open into the chapel, so that the sick and infirm might hear
the service, and, so far as they could, join in it. The chapel contains
an interesting triptych of the fifteenth century by a Flemish artist,
name unknown. One cannot imagine a more desirable haven of rest
than this for those who are fortunate enough to become its inmates.
Enough has now been told to show that among old English towns
Sherborne holds a peculiarly interesting place. It still keeps much of
its old-world look and ancient dignity, and its inhabitants, many of
whom bear the names of the old stock who were living here in in the
time of Henry VI., are a kindly race, among whom it is a pleasure
and a privilege to live.
MILTON ABBEY
By the Rev. Herbert Pentin, M.A.
HE county of Dorset is one of the few counties in
England that contain three great minsters in good repair
and in parochial use—Sherborne, Wimborne, and
Milton. And each of these minsters is of Saxon and
Royal foundation. King Athelstan, the grandson of Alfred
the Great, founded the Monastery and Collegiate Church of Milton
for Secular Canons, in or about the year 938. In the year 964 King
Edgar and Archbishop Dunstan of Canterbury converted the
monastery into an abbey, with forty Benedictine monks, and chose a
very able man, Cynewearde (or Kynewardus), as the first Abbot.
This Cynewearde, a few years afterwards, to the loss of Milton, was
made Bishop of Wells.
The original minster built by Athelstan was a noble stone building
of its time, and was very rich in shrines and relics. The King gave a
piece of our Saviour’s Cross, a great cross of gold and silver with
precious stones, and many bones of the saints, which were placed in
five gilt shrines. The bones of his mother were also brought to the
church (for burial). We also know that the Saxon Minster was
restored and enlarged, if not rebuilt, in Norman times. It has been
reasonably conjectured that the size of the Norman Abbey was that
of the choir and presbytery of the present church. Some large
fragments of Norman masonry have been dug up,[23] which show
that the Norman Abbey was a building of some considerable
architectural pretensions; and encased in the south wall of the
present choir and presbytery are the remains of two enriched
Norman arches which escaped destruction in the fire of 1309. In that
year the church was struck by lightning, and was almost entirely
burnt to the ground. Thirteen years later, however, under Abbot
Walter Archer, the present Abbey Church was commenced on the
same site, but on a much larger and grander scale; and building
operations went on, from time to time, until within a short period
before the Dissolution in 1539.

Milton Abbey.
King Athelstan. “Athelstan’s Mother.”
Founder of Milton Abbey. Buried in Milton Abbey.
(From a Painting in the Church.) (From a Painting in the Church.)

The following styles of architecture are represented in the main


portions of the church, built of stone from Ham Hill and Tisbury:—
First Decorated, the choir and presbytery of seven bays, with aisles;
Second Decorated, the south transept; Third Decorated, the two
western piers of the “crossing”; Perpendicular, the north transept and
central tower. The Perpendicular work was undertaken by the
penultimate Abbot, William de Middleton, assisted by Bishop
Thomas Langton, of Salisbury and of Winchester, the Abbey of
Cerne, and the families of Bingham, Coker, Latimer, Morton, and
others.
At the Dissolution, the Abbey estates were granted by Henry VIII.
to Sir John Tregonwell, who had helped to procure the King’s divorce
from Catharine of Aragon; but the whole of the Abbey Church was
preserved for the parishioners, with the exception of the Ladye
Chapel, which was pulled down, although some of its vaulting shafts
can still be seen outside the east end of the church. The last of the
Abbots (John Bradley, B.D.), after leaving Milton in Tregonwell’s
hands, was consecrated Suffragan Bishop of St. Asaph, with the title
of Bishop of Shaftesbury,[24] and the Abbey Church of Milton then
passed under the sole spiritual control of Richard Hall, Vicar of
Milton, and his successors.
Milton Abbey: Interior.

Unfortunately, the Abbey underwent a “restoration” in 1789, when


the church was despoiled of many of its fittings; and chantry chapels
and other valuable objects of interest went down under the hand of
the “restorer.” But Sir Gilbert Scott, in 1865, restored the church at
the expense of the late Baron Hambro, and left the Abbey in its
present beautiful condition, and, as far as was possible, in its original
state.
The Tabernacle.

The view of the church at the beginning of this chapter will save
the necessity of a description of its exterior. But the interior contains
many things which demand notice.
And first of all must be mentioned the “ornament,” which many
antiquaries consider to be a Tabernacle for reserving the Eucharist.
This very beautiful and richly carved “Sacrament-house” dates from
the fifteenth century, and is made of oak in the form of a spire
composed of four storeys, the lowest containing the opening through
which the reserved elements may have been passed. It is not in its
original position, but is now fastened to the west wall of the south
transept beneath the triforium.
The great altar-screen is a very lofty, beautiful, and peculiarly rich
construction, even though the two long rows of ornamental niches
now lack the statues of the saints that once stood in them—saints
with “very bluff countenances, painted in very bright colours and
heavily gilded.” On its lower portion there is a Latin inscription, which
bids prayers for the souls of William Middleton, Abbot of Milton, and
Thomas Wilken, Vicar of the parish, who worthily decorated
(“honorifice depinxerunt”) the screen in 1492. The three stone sedilia
in the sanctuary are fine specimens. The bosses throughout the
church are of very rich design.
The Abbey also contains two fifteenth century oil paintings of a
crude description, one of which represents Athelstan, the founder,
giving to the first head of the monastery a model of the minster (with
three spires)[25] over which he was to preside. The other painting is
supposed to represent Athelstan’s mother—Egwynna, “femina
illustris.”[26]
The tombs of the abbots within the Abbey are most interesting. In
front of the altar steps there is a Purbeck marble grave-slab of the
fourteenth century, which was once inlaid with the brass figure of an
abbot clad in pontificalia, with a marginal Latin inscription in
Lombardic capitals:
ABBA : VALTERE : TE : FATA : CITO : RAPVERE : TE :
RADINGA : DEDIT : SED : MORS : MALE : NOS : TVA :
LEDIT.
This is the slab of an Abbot of Milton whose Christian name was
Walter, and who was formerly a monk of Reading, probably Walter
de Sydelinge, who died in 1315. In the north transept there is a
thirteenth century grave-slab of another abbot. This slab is also of
Purbeck marble, but the upper portion is broken off. The remaining
portion shows part of an incised figure of an abbot, with pastoral
staff, chasuble, stole, maniple, alb, and an imperfect marginal
inscription in Norman French:
VVS ⁝ KI ⁝ PAR ⁝ I ⁝ CI ⁝ PASSET ⁝ PVR ⁝ LEALME ⁝
PRIE...

...RCI ⁝ LISET ⁝ LE ⁝ PARDVN ⁝ I ⁝ CI[27]


There are other large marble grave-slabs, without inscriptions, in
the church, which are supposed to cover abbots, monks, and
benefactors. On some there are the matrices of missing brasses.
One, in front of the altar steps, shows the outline of a civilian in a
plain gown, and his wife wearing a “butterfly” head-dress, with their
five sons and four daughters, circa 1490. In St. John the Baptist’s
Chapel, at the east end of the north aisle of the church, there is a
small fifteenth century brass to John Artur, one of the monks of the
Abbey, with a Latin inscription, which bids God have mercy on his
soul. In the same chapel, a very fine coloured armorial brass over Sir
John Tregonwell’s altar-tomb contains the latest tabard example on a
brass in England (1565).[28]
But to mention all the ancient or modern memorials (some of
wondrous beauty, such as those of Lord and Lady Milton, and Baron
Hambro) would take far too much space. A marble tablet in the
vestry informs the reader that John Tregonwell, Esquire, who died in
the year 1680, “by his last will and testament gave all the bookes
within this vestry to the use of this Abby Church for ever, as a
thankfuld acknowledgement of God’s wonderfull mercy in his
preservation when he fell from the top of this Church.” This incident
happened when he was a child; he was absolutely uninjured, his stiff
skirts having acted as a parachute.[29] The chained library of sixty-
six leather-bound volumes comprises the works of the Latin and
Greek Fathers and other early Christian writers, and some standard
theological works of the seventeenth century. The books have been
kept at the vicarage for many years.

Abbot Middleton’s Rebus.

The abbey now contains very little painted glass.[30] There is a


large “Jesse window” by the elder Pugin in the south transept, and
some coloured coats of arms and devices of kings, nobles, and
abbots in some of the other windows. The dwarfed east window
contains the only pre-Reformation glass in the church.[31] The
Abbatial Arms are emblazoned in several parts of the building. They
consist of three baskets of bread, each containing three loaves. On
one of the walls in the south aisle, near the vestry, there is the
carved coloured rebus of Abbot William de Middleton, with the date
1514 in Arabic numerals—the 4 being represented by half an eight. It
comprises the letter W with a pastoral staff, and a windmill on a large
cask—in other words, a mill and a tun (Mil-ton). The old miserere
seats still remain in the choir, but the carving thereon is not very
elaborate, and many of them have been renewed. The inscriptions
on the Communion plate (which consists of two large silver barrel-
shaped flagons, a bell-shaped chalice, and a large and a small
paten) tell us that “John Chappell, Sitteson and Stationer of London,
1637,” and “Mary Savage, 1658,” and “Maddam Jane Tregonwell,
widdow, 1675,” gave these to “Milton Abby.”
There are several other interesting things in the church, albeit not
ancient—e.g., the rood-loft, the font, and the pulpit.
The rood-loft, although not entirely ancient, is composed of ancient
materials. When the party-walls of St. John the Baptist’s Chapel, the
chantry of Abbot William de Middleton, and other side-chapels, were
destroyed or mutilated at the “restoration” in 1789, some of the
materials were used to reconstruct the rood-loft. The eastern
cornice, for instance, is probably a portion of Abbot Middleton’s
chantry, and bears thirteen coats of arms, including those of the
Abbeys of Milton, Sherborne, and Abbotsbury, and the families of
Chidiock, Latimer, Lucy, Stafford of Hooke, Thomas of Woodstock,
and others.
The font of the Abbey, in the south transept, is modern, but of
unusual design. It is composed of two beautiful life-sized white
marble female figures, representing Faith and Victory, with a
baptismal shell at their feet.
Near the font is an oak case containing a fourteenth century coffin
chalice and paten, and fragments of a wooden pastoral staff and
sandals, discovered during the restoration of the church in 1865.[32]
The pulpit is also modern, of carved oak; but it is interesting,
because it contains statues of all the patron saints connected with
the Abbey and the parish, and of these there are no fewer than six,
viz.: St. Sampson of Dol, St. Branwalader,[33] St. Mary the Blessed
Virgin, St. Michael the warrior-archangel, St. Catherine of Alexandria,
and St. James the Great.
St. Catherine of Alexandria is the patron-saint of “King Athelstan’s
Chapel,” which stands in the woods at the top of the hill to the east of
the Abbey. And this little church has also had a history well worth the
telling. When Athelstan was fighting for his throne he had to pass
through the county of Dorset, and he encamped on Milton Hill, and
threw up an earthwork, or made use of one already existing there,
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebookfinal.com

You might also like