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

Guide to Java: A Concise Introduction to Programming (2nd Edition) James T. Streib 2024 Scribd Download

Guide

Uploaded by

kahengattia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
23 views

Guide to Java: A Concise Introduction to Programming (2nd Edition) James T. Streib 2024 Scribd Download

Guide

Uploaded by

kahengattia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 55

Download Full Version ebook - Visit ebookmeta.

com

Guide to Java: A Concise Introduction to


Programming (2nd Edition) James T. Streib

https://ebookmeta.com/product/guide-to-java-a-concise-
introduction-to-programming-2nd-edition-james-t-streib/

OR CLICK HERE

DOWLOAD NOW

Discover More Ebook - Explore Now at ebookmeta.com


Instant digital products (PDF, ePub, MOBI) ready for you
Download now and discover formats that fit your needs...

Start reading on any device today!

Concise Guide To Databases: A Practical Introduction


Konstantinos Domdouzis

https://ebookmeta.com/product/concise-guide-to-databases-a-practical-
introduction-konstantinos-domdouzis/

ebookmeta.com

A Concise Introduction to Robot Programming with ROS2 1st


Edition Francisco Martín Rico

https://ebookmeta.com/product/a-concise-introduction-to-robot-
programming-with-ros2-1st-edition-francisco-martin-rico/

ebookmeta.com

Introduction to Programming with Java: A Problem Solving


Approach 3rd Edition John Dean

https://ebookmeta.com/product/introduction-to-programming-with-java-a-
problem-solving-approach-3rd-edition-john-dean/

ebookmeta.com

The Solar System 1 Telluric and Giant Planets


Interplanetary Medium and Exoplanets Sciences 1 1st
Edition Therese Encrenaz (Editor)
https://ebookmeta.com/product/the-solar-system-1-telluric-and-giant-
planets-interplanetary-medium-and-exoplanets-sciences-1-1st-edition-
therese-encrenaz-editor/
ebookmeta.com
Scarhaven Keep 1st Edition J S Fletcher

https://ebookmeta.com/product/scarhaven-keep-1st-edition-j-s-fletcher/

ebookmeta.com

How America Got Its Guns A History of the Gun Violence


Crisis 1st Edition William Briggs

https://ebookmeta.com/product/how-america-got-its-guns-a-history-of-
the-gun-violence-crisis-1st-edition-william-briggs/

ebookmeta.com

Conspiracy Giordano Bruno 5 1st Edition S J Parris

https://ebookmeta.com/product/conspiracy-giordano-bruno-5-1st-edition-
s-j-parris/

ebookmeta.com

Mental Health Disorders Sourcebook (Health Reference), 8th


Edition Kevin Hayes

https://ebookmeta.com/product/mental-health-disorders-sourcebook-
health-reference-8th-edition-kevin-hayes/

ebookmeta.com

Loose Leaf Version for How Children Develop Canadian


Edition Launchpad for How Children Develop Canadian
Edition Siegler
https://ebookmeta.com/product/loose-leaf-version-for-how-children-
develop-canadian-edition-launchpad-for-how-children-develop-canadian-
edition-siegler/
ebookmeta.com
Literature Language and Computing Polina Eismont Maria
Khokhlova Mikhail Koryshev Elena Riekhakaynen

https://ebookmeta.com/product/literature-language-and-computing-
polina-eismont-maria-khokhlova-mikhail-koryshev-elena-riekhakaynen/

ebookmeta.com
Undergraduate Topics in Computer Science

James T. Streib · Takako Soma

Guide to Java
A Concise Introduction
to Programming
Second Edition
Undergraduate Topics in Computer Science

Series Editor
Ian Mackie, University of Sussex, Brighton, UK

Advisory Editors
Samson Abramsky , Department of Computer Science, University of Oxford,
Oxford, UK
Chris Hankin , Department of Computing, Imperial College London, London, UK
Mike Hinchey , Lero – The Irish Software Research Centre, University of
Limerick, Limerick, Ireland
Dexter C. Kozen, Department of Computer Science, Cornell University, Ithaca,
NY, USA
Andrew Pitts , Department of Computer Science and Technology, University of
Cambridge, Cambridge, UK
Hanne Riis Nielson , Department of Applied Mathematics and Computer Science,
Technical University of Denmark, Kongens Lyngby, Denmark
Steven S. Skiena, Department of Computer Science, Stony Brook University, Stony
Brook, NY, USA
Iain Stewart , Department of Computer Science, Durham University, Durham,
UK
Joseph Migga Kizza, College of Engineering and Computer Science,
The University of Tennessee-Chattanooga, Chattanooga, TN, USA
‘Undergraduate Topics in Computer Science’ (UTiCS) delivers high-quality
instructional content for undergraduates studying in all areas of computing and
information science. From core foundational and theoretical material to final-year
topics and applications, UTiCS books take a fresh, concise, and modern approach
and are ideal for self-study or for a one- or two-semester course. The texts are all
authored by established experts in their fields, reviewed by an international advisory
board, and contain numerous examples and problems, many of which include fully
worked solutions.
The UTiCS concept relies on high-quality, concise books in softback format, and
generally a maximum of 275–300 pages. For undergraduate textbooks that are
likely to be longer, more expository, Springer continues to offer the highly regarded
Texts in Computer Science series, to which we refer potential authors.
James T. Streib Takako Soma

Guide to Java
A Concise Introduction to Programming

Second Edition

123
James T. Streib Takako Soma
Program in Computer Science Program in Computer Science
Illinois College Illinois College
Jacksonville, IL, USA Jacksonville, IL, USA

ISSN 1863-7310 ISSN 2197-1781 (electronic)


Undergraduate Topics in Computer Science
ISBN 978-3-031-22841-4 ISBN 978-3-031-22842-1 (eBook)
https://doi.org/10.1007/978-3-031-22842-1

1st edition: © Springer-Verlag London 2014


2nd edition: © The Editor(s) (if applicable) and The Author(s), under exclusive license to Springer
Nature Switzerland AG 2023
This work is subject to copyright. All rights are solely and exclusively licensed by the Publisher, whether
the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of
illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and
transmission or information storage and retrieval, electronic adaptation, computer software, or by similar
or dissimilar methodology now known or hereafter developed.
The use of general descriptive names, registered names, trademarks, service marks, etc. in this
publication does not imply, even in the absence of a specific statement, that such names are exempt from
the relevant protective laws and regulations and therefore free for general use.
The publisher, the authors, and the editors are safe to assume that the advice and information in this
book are believed to be true and accurate at the date of publication. Neither the publisher nor the
authors or the editors give a warranty, expressed or implied, with respect to the material contained
herein or for any errors or omissions that may have been made. The publisher remains neutral with regard
to jurisdictional claims in published maps and institutional affiliations.

This Springer imprint is published by the registered company Springer Nature Switzerland AG
The registered company address is: Gewerbestrasse 11, 6330 Cham, Switzerland
Preface

James T. Streiba,1 and Takako Somaa,2


a
Computer Science Program, Illinois College, Jacksonville, IL, USA
1
Email: james.streib@jtstreib.com.
2
Email: tsoma@ic.edu.

Purpose
The purpose of this text is to help the reader learn very quickly how to program using the
Java programming language. This is accomplished by concentrating on the fundamentals,
providing plenty of illustrations and examples, and using visual contour diagrams to
illustrate the object-oriented semantics of the language.

Comparison to Other Texts


There are a number of texts on the Java programming language. Some of these texts provide
plenty of examples and are very comprehensive, but unfortunately, they sometimes seem
to cover too many details, which might make it difficult for a beginning programmer to
discern which points are the most relevant. There are also other texts that attempt to provide
a shortened introduction to the language, but it seems that these texts might not provide the
necessary examples and illustrations and might be better suited for readers who have
previous programming experience.

Need
This text attempts to fill the gap between the above two types of books. First, it provides
plenty of examples and concentrates primarily on the fundamentals of the Java
programming language so that the reader can stay focused on the key concepts. Second, by
concentrating on the fundamentals, it allows the text to be more concise and yet still
accessible to readers who have no prior programming experience. The result is that the
reader can learn the Java programming language very quickly and also have a good
foundation to learn more complex topics later.

Features of This Text


This text provides many examples and illustrations. It further has an early introduction to
object-oriented programming and uses contour diagrams to illustrate various object-
oriented concepts. The contour model was originally developed by John B. Johnson [4].
The model was elaborated on by Organick, Forsythe, and Plummer to illustrate
subprograms, parameter passing, and recursion in procedural and functional languages [7].
The model seems quite adaptable to newer programming methodologies such as object-
oriented programming as illustrated in a paper by the authors of this text [8]. As discussed
in that paper, it was shown that the use of contour diagrams can be an effective tool in

v
vi Preface

helping one learn object-oriented concepts in the Java programming language. By


acquiring a good working model of objects, there is less chance of possible misconceptions.
In many places in the text, questions are asked of the reader to help them interact with
the material and think about the subject matter just presented. Hopefully the reader will
take a few moments to try to answer these questions on their own before proceeding to the
answer that follows. To help further reinforce concepts, each chapter has one or more
complete programs to illustrate many of the concepts presented and also to help readers
learn how to write programs on their own. In addition, for review and practice, there are
summaries and exercises provided at the end of each chapter. Further, in the appendices at
the end of the text, there are answers to selected exercises and a glossary of important
terms. A summary of the features of this text are listed below:
‡ Stresses the fundamentals.
‡ Provides many examples and illustrations.
‡ Has an early introduction to objects.
‡ Uses contour diagrams to illustrate object-oriented concepts.
‡ Asks readers questions to help them interact with the material.
‡ Has one or more complete programs in every chapter.
‡ Provides chapter summaries.
‡ Includes exercises at the end of each chapter, with selected answers in an appendix.
‡ Has a glossary of important terms.

Features New to the Second Edition

The second edition retains all the features of the first edition. In addition to fixing any
known errors, any areas that could be clarified have been reworded. Features new to the
second edition, include the following:

‡ Chapter 1 has been reorganized into Chapters 0 and 1. Whereas an experienced


programmer can go straight to Chapter 1, it is recommended a new programmer or an
experienced programmer who wants a review start with the computer concepts in
Chapter 0.
‡ Chapter 0 contains new topics such as computational thinking and computer ethics.
‡ Where previously some topics in Chapter 1 were scattered in different sections, they
have been consolidated into single sections to help the reader focus on each topic
individually.
‡ Simple graphical user interface (GUI) is introduced in Chapter 1 and used in different
sections throughout the text.
‡ Chapter 11 has been added to include an introduction to bit-wise logic for computer
science students taking computer organization in the future or for pre-engineering
students to gain exposure to some of the logic capabilities in the C-like languages.
‡ Chapter 12 introduces parallel processing programming for computer science students
who will be taking a course in operating systems in the future.
‡ Appendix A contains a detailed description of the Java skeleton introduced in Chapter
1 along with additional information on standard output and GUI.
‡ Additional exercises have been added to various chapters.
Preface vii

Overview of the Chapters


This text first introduces the reader to various computer concepts such as hardware,
software, computational thinking, software design, and computer ethics. It then allows the
reader to understand a simple program with the appropriate input, processing, and output,
followed by an early introduction to objects. It then looks at selection and iteration
structures followed by more object-oriented concepts. Next, strings and arrays are
examined. This is followed by recursion, inheritance and polymorphism, and elementary
files. Then there is an introduction to bit-wise logic and parallel processing. The appendices
include information on the Java skeleton, standard output, graphical input/output,
exception processing, Javadoc, a glossary, and answers to selected exercises. Lastly, there
are references, useful websites and an index. The following provides a brief synopsis of
the chapters and appendices:
.
‡ Chapter 0 begins with the computer concepts of hardware/software, computational
thinking, design, and computer ethics.
‡ Chapter 1 provides an introduction to variables, input/output, and arithmetic
operations.
‡ Chapter 2 introduces objects and contour diagrams.
‡ Chapter 3 explains selection structures.
‡ Chapter 4 shows how iteration structures work.
‡ Chapter 5 revisits object-oriented concepts.
‡ Chapter 6 introduces string variables and processing.
‡ Chapter 7 illustrates arrays and array processing.
‡ Chapter 8 examines recursion.
‡ Chapter 9 explores inheritance and polymorphism.
‡ Chapter 10 discusses elementary files.
‡ Chapter 11 describes how bit-wise logic works
‡ Chapter 12 introduces parallel processing programming.
‡ Appendix A elaborates on the Java skeleton, standard output, and graphical
input/output.
‡ Appendix B discusses elementary exception processing.
‡ Appendix C presents the basics of Javadoc.
‡ Appendix D lists a glossary of key terms.
‡ Appendix E provides answers to selected exercises.

Ordering of the Chapters

Typically, there are three ways objects can be introduced to the beginning programmer:

‡ Objects first.
‡ Objects last.
‡ Objects interleaved.

This text takes the latter approach where objects are discussed in Chapters 2, 5, and 9.
However, recognizing that some readers and instructors might want to use one of the first
two approaches, this text can be read using alternative orders. For example, should an
viii Preface

objects first approach want to be taken, after reading Chapter 1, Chapters 2 and 5 can be
read next, followed by Chapters 3 and 4. Should an object later approach want to be used,
Chapters 3 and 4 can be read prior to Chapters 2 and 5.

To help facilitate these alternative approaches, starting with Chapter 3, the Complete
Program sections at the end of each chapter have examples with and without using objects.
Note that Chapter 9 requires an understanding of arrays, which is covered in Chapter 7,
and it can be read after completing that chapter.

Scope
As mentioned previously, this text concentrates on the fundamentals of the Java
programming language such as input/output, object-oriented programming, arithmetic and
logic instructions, control structures, strings, arrays including elementary sorting and
searching, recursion, files, bit-wise logic, and parallel processing programming. As a result,
it might not cover all the details that are found in some other texts, and if necessary, these
topics can be supplemented by the instructor or reader, or covered in a subsequent text
and/or second semester course.

Audience
This text is intended primarily for readers who have not had any previous programming
experience; however, this does not preclude its use by others who have programmed
previously. It can serve as a text in an introductory programming course, as an introduction
to a second language in a practicum course, as a supplement in a course on the concepts of
programming languages, or as a self-study guide in either academe or industry. Although
no prior programming is assumed, it is recommended that readers have the equivalent of
an introduction to functions course that includes trigonometry which will help with
problem solving and understanding the examples presented in the text.

Acknowledgments
In addition to the reviewers of the first edition, the authors would like to thank Mark E.
Bollman of Albion College and James W. Chaffee of the University of Iowa for their
continued work on this edition. Also, the authors would like to acknowledge the students
of Illinois College who have read and used various sections of the first edition in the
classroom. On a personal note, James Streib would like to thank his wife Kimberly A.
Streib and son Daniel M. Streib. Takako Soma would like to thank her family and friends,
near and far.
Note that Java is a registered trademark of Oracle and/or its affiliates and that Windows
is a registered trademark of Microsoft Corporation in the United States and/or other
countries.

Feedback
The possibility of errors exist in any text, therefore any corrections, comments, or
suggestions are welcome and can be sent to the authors via the e-mail addresses below. In
addition to copies of the complete programs presented in the text, any significant
corrections can be found at the website below.
Preface ix

Website: http://www.jtstreib.com/GuideJavaProgramming.html

Illinois College James T. Streib


Jacksonville, IL, USA james.streib@jtstreib.com
October 1, 2022 Takako Soma
tsoma@ic.edu
Contents

0 Introduction to Computing Concepts 1


0.1 Introduction 1
0.2 Overview of Hardware and Software 1
0.2.1 Hardware 1
0.2.2 Software 2
0.2.3 History and Java 3
0.2.4 High-level Translation 3
0.3 Introduction ro Computational Thinking 5
0.4 Essentials of Software Design 7
0.4.1 Syntax, Semantics, and Errors 7
0.4.2 Design Methodology 8
0.4.2.1 Analysis 9
0.4.2.2 Design 9
0.4.2.3 Implementation 9
0.4.2.4 Maintenance 10
0.4.3 Tools and Techniques 10
0.4.3.1 Pseudocode 10
0.4.3.2 OOP and UML 11
0.4.3.3 Debugging 11
0.5 A Brief Look at Computer Ethics 12
0.6 Summary 13
0.7 Exercises (Items Marked with an * Have Solutions in Appendix E) 14

1 Variables, Input/Output, and Arithmetic 17


1.1 Introduction 17
1.2 Java Skeleton 16
1.3 ³+HOOR:RUOG´ 17
1.3.1 Text-based Output 17
1.3.2 GUI-based Output 18
1.4 Variables and Constants 19
1.5 Assignment Statements 23
1.6 Output 26
1.6.1 Text-based 26
1.6.2 GUI-based 30
1.7 Input 31
1.7.1 Text-based 31
1.7.2 GUI-based 34
1.8 Arithmetic Statements 36
1.8.1 Binary Operators 36
1.8.2 Precedence 38
1.8.3 Unary Operators 39
1.8.4 Incrementing 40

xi
xii Contents

1.8.5 Summing 41
1.8.6 Arithmetic Functions 42
1.9 Comments 43
1.10 Complete Program: Implementing a Simple Program 44
1.11 Summary 46
1.12 Exercises (Items Marked with an * Have Solutions in Appendix E) 47

2 Objects: An Introduction 51
2.1 Introduction 51
2.2 Classes and Objects 51
2.3 Public and Private Data Members 52
2.4 Value-Returning Methods 52
2.5 void Methods and Parameters 53
2.6 Creating Objects and Invoking Methods 54
2.7 Contour Diagrams 56
2.8 Constructors 62
2.9 Multiple Objects and Classes 66
2.10 Unified Modeling Language (UML) Class Diagrams 73
2.11 Complete Program: Implementing a Simple Class and
Client Program 75
2.12 Summary 77
2.13 Exercises (Items Marked with an * Have Solutions in
Appendix E) 78

3 Selection Structures 83
3.1 Introduction 83
3.2 If-Then Structure 83
3.3 If-Then-Else Structure 88
3.4 Nested If Structures 91
3.4.1 If-Then-Else-If Structure 91
3.4.2 If-Then-If Structure 94
3.4.3 Dangling Else Problem 96
3.5 Logical Operators 99
3.6 Case Structure 105
3.7 Complete Programs: Implementing Selection Structures 111
3.7.1 Simple Program 111
3.7.2 Program with Objects 114
3.8 Summary 116
3.9 Exercises (Items Marked with an * Have Solutions in Appendix E) 116

4 Iteration Structures 121


4.1 Introduction 121
4.2 Pretest Indefinite Loop Structure 121
4.2.1 Count-Controlled Indefinite Iteration Structure 122
4.2.2 Sentinel Controlled Loop 128
4.3 Posttest Indefinite Loop Structure 134
4.4 Definite Iteration Loop Structure 137
Contents xiii

4.5 Nested Iteration Structures 140


4.6 Potential Problems 141
4.7 Complete Programs: Implementing Iteration Structures 142
4.7.1 Simple Program 143
4.7.2 Program with Objects 145
4.8 Summary 150
4.9 Exercises (Items Marked with an * Have Solutions in Appendix E) 150

5 Objects: Revisited 155


5.1 Sending an Object to a Method 155
5.2 Returning an Object from a Method 158
5.3 Overloaded Constructors and Methods 161
5.3.1 Overloaded Constructors 161
5.3.2 Default Constructors 163
5.3.3 Overloaded Methods 164
5.4 Use of the Reserved Word this 165
5.5 Class Constants, Variables, and Methods 169
5.5.1 Local, Instance, and Class Constants 169
5.5.2 Local, Instance, and Class Variables 176
5.5.3 Class Methods 178
5.6 Complete Programs: Implementing Objects 180
5.6.1 Program Focusing on Overloaded Methods 180
5.6.2 Program Focusing on Class Data Members and Class
Methods 189
5.7 Summary 193
5.8 Exercises (Items Marked with an * Have Solutions in Appendix E) 193

6 Strings 203
6.1 Introduction 203
6.2 String Class 203
6.3 String Concatenation 204
6.4 Methods in String Class 206
6.4.1 The length Method 206
6.4.2 The indexOf Method 206
6.4.3 The substring Method 207
6.4.4 Comparison of Two String Objects 209
6.4.5 The equalsIgnoreCase Method 211
6.4.6 The charAt Method 212
6.5 The toString Method 213
6.6 Complete Program: Implementing String Objects 215
6.7 Summary 219
6.8 Exercises (Items Marked with an * Have Solutions in Appendix E) 219

7 Arrays 223
7.1 Introduction 223
7.2 Array Declaration 223
xiv Contents

7.3 Array Access 224


7.4 Input, Output, Simple Processing, and Methods 226
7.4.1 Input 226
7.4.2 Output 230
7.4.3 Simple Processing 230
7.4.4 Passing an Array to and from a Method 231
7.5 Reversing an Array 232
7.6 Searching an Array 237
7.6.1 Sequential Search 237
7.6.2 Binary Search 238
7.6.3 Elementary Analysis 240
7.7 Sorting an Array 241
7.7.1 Simplified Bubble Sort 241
7.7.2 Modified Bubble Sort 244
7.8 Two-Dimensional Arrays 245
7.8.1 Declaration, Creation, and Initialization 245
7.8.2 Input and Output 247
7.8.3 Processing Data 248
7.8.4 Passing a Two-Dimensional Array to and from a Method 251
7.8.5 Asymmetrical Two-Dimensional Arrays 253
7.9 Arrays of Objects 255
7.10 Complete Program: Implementing an Array 258
7.11 Summary 261
7.12 Exercises (Items Marked with an * Have Solutions in Appendix E) 262

8 Recursion 265
8.1 Introduction 265
8.2 The Power Function 265
8.3 Stack Frames 274
8.4 Fibonacci Numbers 277
8.5 Complete Program: Implementing Recursion 289
8.6 Summary 291
8.7 Exercises (Items Marked with an * Have Solutions in Appendix E) 291

9 Objects: Inheritance and Polymorphism 293


9.1 Inheritance 293
9.2 Protected Variables and Methods 303
9.3 Abstract Classes 304
9.4 Polymorphism 306
9.5 Complete Program: Implementing Inheritance and Polymorphism 310
9.6 Summary 315
9.7 Exercises (Items Marked with an * Have Solutions in Appendix E) 316

10 Elementary File Input and Output 321


10.1 Introduction 321
10.2 File Input 321
10.3 File Output 326
Contents xv

10.4 File Input and Output Using an Array 328


10.5 Specifying the File Location 332
10.6 Complete Programs: Implementing File Input and Output 334
10.6.1 Matrix Multiplication 334
10.6.2 Sorting Data in a File 336
10.7 Summary 338
10.8 Exercises (Items Marked with an * Have Solutions in Appendix E) 338

11 Bit Manipulation 341


11.1 Introduction 341
11.2 Simple Conversions 341
11.3 Declaration and Assignments 343
11.4 Bit-wise Logic Operations 344
11.5 Testing, Clearing, Setting, and Toggling 346
11.6 Shifting 348
11.7 Precedence 350
11.8 Complete Program: Implementing Bit-wise Operators 351
11.9 Summary 355
11.10 Exercises (Items Marked with an * Have Solutions in Appendix E) 355

12 Introduction to Parallel Processing Programming 356


12.1 Multiprossor Systems 359
12.2 Programming Multicore and SharedMemory Multiprocessor
Using Pyjama 360
12.2.1 Using Pyjama to Write Multithreaded Programs 360
12.2.2 ³Hello World´ 361
12.2.3 Sorting Building Blocks 363
12.3 Analysis 368
12.4 Complete Program: Implementing Paralle Inner Product 370
12.5 Summary 372
12.6 Exercises (Items Marked with an * Have Solutions in Appendix E) 372

Appendix A Explanation and Elaboration of Concepts in Chapter 1 375


A.1 6NHOWRQ3URJUDPDQG³+HOOR:RUOG³ 375
A.2 Text-base Output: print and println 376
A.3 Text-based Input 378
A.4 Overview of Java Packages 379
A.5 More on GUI-based Output and Input 380
A.6 Confirmation Dialog Boxes 383
A.7 Option Dialog Boxes 384

Appendix B Exceptions 387


B.1 Exception Class and Error Class 387
B.2 Handling an Exception 388
B.3 Throwing Exceptions and Multiple catch Blocks 391
B.4 Checked and Unchecked Exceptions 396
xvi Contents

Appendix C Javadoc Comments 


C.1 Javadoc 
C.2 More Javadoc Tags 
C.3 Generating Javadoc Documentation from a Command Line 

Appendix D Glossary 

Appendix E Answers to Selected Exercises 

References and Useful Websites 

Index 
0
Introduction to Computing Concepts
James T. Streiba* and Takako Somaa
a
Computer Science Program, Illinois College, Jacksonville, IL, USA

Abstract
In addition to an introduction to hardware and software concepts, including the concept of compiling,
interpreting, and executing a program, there is an introduction to computational thinking, software design,
and computer ethics.

Keywords
Hardware, Software, Computational Thinking, Software Design, Computer Ethics.

0.1 Introduction

Although this chapter is labeled as Chapter 0, that does not diminish its importance. The
reason for such a numbering is to allow readers with a previous introduction to computing
concepts and programming to proceed onto Chapter 1. However, for readers with no prior
introduction or for those who would like a refresher, this chapter provides an important
overview of hardware, software, computational thinking, software design, and computer
ethics.

0.2 Overview of Hardware and Software

0.2.1 Hardware
As many readers may already know from using application software such as a word
processor, a computer system is composed of two major parts: hardware and software.
Since this book is primarily about writing software, this section on hardware is
understandably brief. The hardware is the physical computer that includes five basic
components: the central processing unit (CPU), the random-access memory (RAM) or just
memory for short, input (typically a keyboard), output (typically a monitor), and storage
(often a disk) as shown in Fig. 0.1.

© The Author(s), under exclusive license to Springer Nature Switzerland AG 2023 1


J. T. Streib and T. Soma, Guide to Java, Undergraduate Topics in Computer Science,
https://doi.org/10.1007/978-3-031-22842-1_0
2 0 Introduction to Computing Concepts

CPU

Input Output
RAM

Storage

Fig. 0.1 Computer hardware

0.2.2 Software

In order for computer hardware to perform, it is necessary that it has software.


Essentially, software (often called a program) is the set of instructions that tells the
computer what to do and when to do it. A program is typically loaded from storage into the
FRPSXWHU¶V 5$0 IRU VXEVHTXHQW H[HFXWLRQ LQ WKH FRPSXWHU¶V &38 $V WKH SURJUDP
executes or runs, it will typically ask the user to input data which will also be stored in
RAM. The program will then process the data, and various results will be output to the
monitor. This Input, Process, Output sequence is sometimes abbreviated as IPO.
The only type of instruction a computer can actually understand is low-level machine
language, where different types of CPUs can have different machine languages. Machine
language is made up of ones and zeros, which makes programming in machine language
very tedious and error-prone. An alternative to using machine language is assembly
language which is also a low-level language that uses mnemonics (or abbreviations) and is
easier to use than ones and zeros [10].
However, if the only language that the computer can directly understand is machine
language, how does the computer understand assembly language? The answer is that the
assembly language is translated into machine language by another program called an
assembler (see Fig. 0.2). Note that there is a one-to-one correspondence between assembly
language and machine language, and for every assembly language instruction, there is
typically only one machine language instruction. However, even though assembly
language is easier to program in than machine language, different types of CPUs can also
have different types of assembly languages, so the assembly language of one machine can
be different from that of another machine and needs a seperate assembler.
0.2 Overview of Hardware and Software 3

Compiler Assembler

High-Level Assembly Machine


Language Language Language

Fig. 0.2 Assemblers and compilers

0.2.3 History and Java

The solution to making programming easier and allow programs to be used on different
machines is through the use of high-level languages which are more English-like and math-
like. One of the first high-level programming languages was FORTRAN (FORmula
TRANslation), which was developed in the early 1950s to help solve mathematical
problems. There have been a number of high-level languages developed since that time to
meet the needs of many different users. Some of these include COBOL (COmmon
Business Oriented Language) developed in the 1950s for the business world, BASIC
(Beginners All-purpose Symbolic Instruction Code) developed in the 1960s for beginning
programmers, Pascal in the 1970s previously used for teaching computer science students,
C in the 1970s for systems programming, and C++ in the 1980s for Object-Oriented
Programming (OOP).

Java is also an OOP language that was developed at Sun MicroSystems (which is now
a subsidiary of Oracle Corporation) and was released in 1995. OOP is a programming
methodology that makes it more convenient to reuse software and will be discussed further
in Chaps. 2 , 5 , and 9 .

Although no prior programming experience is necessary to learn Java in this text,


programmers with experience in C or C++ will recognize a number of similarities between
Java and these languages. Conversely, programmers learning Java first will also notice a
number of similarities should they subsequently learn C or C++. The reason for this
similarity between these languages is that both Java and C++ are based on C. Since Java
does not contain some of the features of C++ (such as operator overloading and multiple
inheritance, where overloading and inheritance will be discussed in Chaps. 5 and 9 ), it
is an easier language to learn.

0.2.4 High-level Translation

If high-level languages are easier to learn and use, how can they be implemented on a
computer that can only understand machine language? Similar to assembly language
needing an assembler, the program needed to translate a high-level language to a low-level
language is a compiler or an interpreter. Although there is a one-to-one correspondence
between assembly language and machine language, there is a one-to-many correspondence
4 0 Introduction to Computing Concepts

between a high-level language and a low-level language. This means that for one high-
level language instruction, there can be many low-level assembly or machine language
instructions. Even though different CPUs need different compilers or interpreters to
convert a particular high-level language into the appropriate machine language, compilers
and interpreters allow the same high-level language to be used on different CPUs.
The difference between a compiler and an interpreter is that a compiler will translate
the high-level language instructions for the entire program to the corresponding machine
language for subsequent execution, whereas an interpreter will translate and then execute
each instruction one at a time. Further, a compiler might translate directly to machine
language, or it might translate the high-level language to assembly language, and then let
an assembler convert the assembly language program to machine language as shown in
Fig. 0.2. Once the machine language is created, it is subsequently loaded into the
FRPSXWHU¶V5$0DQGH[HFXWHGE\WKH&38
As mentioned above, an interpreter works slightly differently than a compiler. Instead
of converting an entire high-level program into machine language all at once and then
executing the machine language, an interpreter converts one line of the high-level program
to machine language and then immediately executes the machine language instructions
before proceeding on with the converting and executing of the next high-level instruction
(see Fig. 0.3). The result is that compiler-generated code executes faster than interpreted
code because the program does not need to be converted each time it is executed. However,
interpreters might be more convenient in an educational or development environment
because of the many modifications that are made to a program which require a program to
be converted each time a change is made.

Compile Interpreter

High-Level Machine High-Level Machine

Instruction1 10101010 Instruction1 10101010


01010101 01010101

Instruction2 00110011 Instruction2 00110011


11101110 11101110

Instruction3 00001111 Instruction3 00001111


11110000 11110000

1. Translate all the instructions 1. Translate one instruction at a time

2. Then execute all the machine 2. And then execute only the corresponding
instructions machine instructions

Fig. 0.3 Compilers and interpreters


0.2 Overview of Hardware and Software 5

Java is somewhat unique in that it uses both a compiler and an interpreter to convert the
high-level instructions to machine language. A compiler is used to convert the Java
instructions into an intermediate-level language known as bytecode, and then the bytecode
is converted into machine language using an interpreter.

Since the intent of Java was for portability on the World Wide Web, the advantage of
using both a compiler and an interpreter is that most of the translation process can be done
by the compiler, and when bytecode is sent to different types of machines, it can be
translated by an interpreter into the machine language of the particular type of machine that
the code needs to be run on (see Fig. 0.4).
Note that just as there can be a one-to-many relationship between high-level and low-
level instructions, there can be a one-to-many relationship between Java and bytecode.
However, unlike the one-to-one relationship between assembly language and machine
language, there can also be a one-to-many relationship between bytecode and machine
language, depending on the machine for which the bytecode is being interpreted.

Interpreter
Compiler

Java Bytecode Machine

Instruction1 Bytecode 10101010


Bytecode 01010101

Instruction2 Bytecode 00110011


11101110

Instruction3 Bytecode 00001111


Bytecode 11110000

1. Translate all the Java instructions 2. Then translate one bytecode


instruction at a time

3. And then execute only the corresponding


machine instructions

Fig. 0.4 Java instructions, bytecode, and machine language

0.3 Introduction to Computational Thinking


$FFRUGLQJWR:LQJ³&RPSXWDWLRQDOWKLQNLQJLVXVLQJFRQFHSWVIURPFRPSXWHUVFLHQFHWR
VROYHSUREOHPVDQGGHVLJQV\VWHPV´>@$VFDQEHVHHQLQWKHIROORZLQJFKDSWHUV
in order to write a good program, a number of techniques need to be used, including
decomposition, pattern recognition, abstraction, algorithms, and logical thinking.
Decomposition is used to break down problems into smaller sections, which makes
complex problems more manageable. Pattern recognition is the process of finding
similarities to previously solved problems. Then, the same solution or a slightly modified
6 0 Introduction to Computing Concepts

solution can be used to solve new problems. Abstraction is the filtering out of
unnecessary information. In other words, taking a step back from the specific details and
focusing on the big picture allows one to create a more generic solution. Algorithms are
step-by-step instructions to solve a problem. It is important to create a plan, an algorithm,
for the solution when solving a problem. Logical thinking is deductive inference of new
information on existing information. Computational thinking is a problem-solving
process that involves a number of core principles from computer science as mentioned
above.

But how can these principles be used in non-programming context, for example, solving
the Tower of Hanoi game? The Tower of Hanoi game consists of three pegs, and initially
one of the non-centered pegs contains several rings stacked in order of descending
diameter from bottom to top. The goal is to move the stack of rings to another non-
centered peg as shown in the Fig. 0.5.

Initial state Final state

Fig. 0.5 Tower of Hanoi game

During the process, only one ring can be moved at a time which means only a top ring is
removed among the towers at any given time. Consequently, several rings cannot be
moved at once. Another rule is that a bigger ring cannot be placed on the top of a smaller
one. At the start of the game, the only ring that can be moved is the smallest ring and it
may be placed on one of the two pegs. Next, there are two rings that can be moved. There
is no good reason to move the smallest one back to the original stack or to another peg.
So, the next move should be moving the second smallest ring. As it cannot be stacked on
the top of the smallest one, naturally it goes on the other peg. By understanding the rules,
logical thinking is used to determine the next step. When making a move, do not be
distracted by color of the rings or pegs, nor the sounds they make, but focus on the rings.
This is simplifying the problem using abstraction. As in Fig. 0.6 after successive moves,
there is a point where the largest ring is on one peg and rest of the rings are stacked on
another peg in order the largest to the smallest from the bottom to the top. Realize that
during the moves, a ring can be placed on the top of any ring that is bigger than itself, not
merely the next larger ring.
0.3 Introduction to Computational Thinking 7

Fig 0.6 The largest ring in the final position

Now the task is to move the stack that has one smaller number of rings. During the
process there will be a situation where the second largest ring is on the top of the largest
one and the rest of the rings are stacked in correct order on another peg as shown in Fig.
0.7.

Fig 0.7 The largest and the second largest rings in the final position

Notice that every time the largest ring of the particular stack is placed in the final
position, the next problem is to solve the same problem with one less number of rings,
which means the task to solve the Tower of Hanoi game is divided into smaller problems
using decomposition. Also realize that the same technique can be used to solve the
problem with different sizes by seeing the pattern. Making a plan of where to moving a
ring is step-by-step procedure, which is an algorithm.

Computer scientists naturally use computational thinking when writing programs,


however, as can be seen in the Tower of Hanoi example, it also allows non-computer
scientists to benefit from a computational approach to problem-solving. Many disciplines
have been influenced by computational thinking in some way, including statistics,
biology, engineering, and economics. As computational thinking can be applied in
everyday life, currently there is an initiative to introduce computational thinking skills to
primary and secondary school children as well as reinforcing them at the college level.

0.4 Essentials of Software Design

0.4.1 Syntax, Semantics, and Errors


During the process of translating a language to machine language, the translator catches
certain types of errors. Before looking at the various types of errors, a distinction should
8 0 Introduction to Computing Concepts

be made between the syntax and the semantics of a program. Simply stated, the syntax is
the grammar of the language, and the semantics is the meaning or what each instruction
does. To explain further, syntax is the spelling of the individual words, where the
semicolons go, and so on. If mistakes are made, a compiler will detect what are known as
syntax errors, generate messages to the programmer, and the program will not be compiled
or executed. Although syntax is very important, there is a tendency for first-time
programmers to spend too much time learning syntax to avoid syntax errors. However,
there must be equal time spent on semantics to ensure that the program does what the
programmer intended it to do.
Even though there might not be any syntax errors, there can be what are called execution
errors or run-time errors, such as division by zero. When these types of errors occur, the
appropriate error messages are generated and execution stops. Even worse, there can also
be logic errors, which are mistakes in the logic of the program so that the program does
not do what was intended. The unfortunate aspect of logic errors is that they do not produce
any error messages which can make them extremely difficult to find and fix.

0.4.2 Design Methodology


When writing a program for the first time, there is a tendency to want to just start keying
the program into the computer and get it to work. As a result, many beginning programmers
focus primarily on the syntax of their program because they want to avoid getting syntax
errors. Initially this method of just typing in a program appears to work fairly well when
programs are small at the beginning of a class and in the text. However, as problems get
more complex and they become more difficult to solve, the programs written this way will
tend to have not only more syntax errors but complicated logic errors which are more
difficult to correct since no error messages are provided.

As an analogy, an individual might be able to build a small storage shed by just sawing
and nailing some lumber together without worrying about the overall design of the project.
However, with a larger project such as a house, apartment building, or office building, that
methodology would not be sufficient. Instead, there are many other people who must be
consulted, including the original customer who wants the building built, the architects who
work with the customer, the contractors, and the carpenters. The same holds true in the
world of programming where a programmer and/or systems analyst works with others such
as customers, users, and managers.

What are needed are various strategies and tools to help write programs correctly to
minimize logic errors. Just as in the above example where blueprints and plans are used by
the architect, there are techniques that can be used by analysts, software engineers, and
programmers. Although the complete process for developing software might not be needed
initially with smaller programs, it does not hurt to practice the various techniques on
smaller programs to gain familiarity, so that when one advances to more difficult projects,
one is comfortable with many of the techniques. Although the following techniques are
used primarily with non-object-oriented programs, they can be augmented with object-
oriented design techniques introduced in chapter 2 and used in larger programs.
0.4 Essentials of Software Design 9

There are many different methodologies and number of stages within the various
methodologies for solving problems that can be found in different texts, but upon closer
examination, they are all rather similar. They tend to include at least four stages, and they
are usually comparable to the following:
1. Analysis
2. Design
3. Implementation
4. Maintenance
0.4.2.1 Analysis
The analysis stage is where the needs of the user or customer are first determined.
Questions concerning the form and quantity of the input, the type of processing that needs
to be done, the storage requirements of data, and the type of output needed are asked and
clarified at this stage. This would be similar to a customer in a construction project trying
to determine what type of building should be built. In a first semester programming class,
this stage may or may not be included. Sometimes a professor might have already
completed the analysis stage and included what is needed in the programming assignment.
However, at other times, they might require this stage and a number of questions will need
to be asked by the student. This might be especially true when working on a team project
in a software design or senior capstone course.

0.4.2.2 Design

The design stage is where a project begins to take shape. It is similar to the architect
creating a set of blueprints and models for the user to examine, because changes are much
easier to make on paper or with the model than once the construction of the building has
started. Various tools such as pseudocode and Unified Modeling Languge (UML) diagrams
(discussed shortly) are used by systems analysts, software engineers, and programmers to
help design the program. Again, it is much easier to make changes during the design phase
than after the programming has begun.

0.4.2.3 Implementaion

The implementation stage is where the code is actually written, entered, compiled, and
syntax errors are corrected. Once the code is free of syntax errors, it is thoroughly tested.
This includes testing various components of the program to be sure each section is working
properly. If not, the code needs to be debugged to correct any logic errors. In addition to
the various components, the entire program needs to be tested to ensure that all the
components work together as planned. Sometimes errors are a result of not following the
design, whereas other times, it is not necessarily the code but rather the design itself that
has the error, in which case one has to go back and correct the error in the design. The
result is that the stages above do not necessarily need to be rigorously adhered to, but rather
when at a stage one may need to return to a previous stage for clarification or to fix a
possible error.
10 0 Introduction to Computing Concepts

Although it is tempting to jump directly to the implementation stage, this tendency


should be avoided. It is important to take the time to properly design the algorithm first
before starting to key in a program. An algorithm is a step-by-step sequence of instructions,
not necessarily implemented on a computer. Once an algorithm is implemented in a
specific language, it is then a program. By taking the time to design a well-thought-out
algorithm, there will be fewer logic errors in the program. Although it might seem to take
longer to include the design stage, the savings will be more than made up for in less time
spent fixing logic errors later.

0.4.2.4 Maintenance

The maintenance stage is where all the modifications and updates take place. In an
industrial strength program, more time is spent in the maintenance phase than all of the
three preceding stages. This is because once a program is up and running, there can be
numerous changes that need to be made over the lifetime of a program. This is another
reason why a program should be designed well in order to facilitate modifications later in
the life of a program. Unfortunately, beginning programmers do not often experience this
stage of a program, because once the concepts are learned from one programming
assignment, the program is often not used again and another program is assigned to
introduce the next set of concepts. However, in some upper-level courses, the assignments
get longer, existing programs might be modified and reused, and students get to have some
experience with the maintenance stage of programs. Regardless, it helps even beginning
students to design well-thought-out programs to gain practice in the event that a professor
decides it might be easier to modify an existing program rather than having to design a new
program from scratch, as done in the real world.

0.4.3 Tools and Techniques

0.4.3.1 Pseudocode

One technique that can help during the design stage is the use of pseudocode.
Pseudocode is a combination of English and a programming language. Since it is not a
SURJUDPPLQJODQJXDJHWKLVLVWKHUHDVRQIRULWVQDPHDV³SVHXGR´FRGH7KHDGYDQWDJHRI
using pseudocode is that one can concentrate on the logic of an algorithm and not worry
about the syntax of a particular programming language. In fact, well-written pseudocode
should be understood by any programmer regardless of the programming language that
they use, and they should be able to convert the pseudocode into their particular
programming language. However, there can be many different versions and levels of detail
WKDWFDQEHLQFOXGHGLQSVHXGRFRGHVRLWLVEHVWWRFKHFNZLWKRQH¶VLQVWUXFWRURUFRPSDQ\
for any preferences or standards that are employed. As a simple example, consider the
following pseudocode on the left compared to the Java statement on the right:

Calculate the area of a rectangle areaRec = height * width;

At this time it is not nececessary to understand the Java code on the right. However, note
that the verbal description on the left is much easier to understand than the detailed Java
0.4 Essentials of Software Design 11

code. As a result, one does not need to concentrate on the intricate syntax, but rather the
semantics. As an alternative, notice the more specific pseudocode on the left.

areaRec height x width areaRec = height * width;

Both the pseudocode and the Java code are known as assignment statements as will be
discussed in the next chapter. Note that an arrow is used in the pseudocode instead of an
equal sign in the Java code to indicate an assignment statement. This helps illustrate the
direction of assignment, since some languages use symbols other than an equal sign to
illustrate assignment. Also notice that a mathematical symbol is used instead of an asterisk
to illustrate multiplication. Lastly, a semicolon is not used since not all other languages use
them to terminate statements.
The result is that the pseudocode in the second example is more specific than the first
example which helps with the translation to Java, but it is also more generic than the Java
statement which helps in the translation to other languages as well. Again, these are just
two samples of pseudocode, so be sure to check your local guidelines and requirements
which should be used. In this text, when pseudocode is used, it will be written with as much
detail as possible so as not to be ambiguous and to help with the translation into Java.
0.4.3.2 OOP and UML
Since the term object has been used previously, what is an object? In the past, programs
were often written with large sections of code that were not very helpful to reuse when
another program needed to be written.
It can help with the understanding of the idea of objects to think of an automobile. An
automobile has many different parts such as steering mechanisms, transmissions, brakes,
etc. Instead of designing the transmission as unique to only one type of auto, a generic plan
for a transmission can be designed first. Then particular versions of the transmission could
be built to be put into different types of automobiles. The plans for the transmission can be
thought of as a class and the differing versions of the transmission as instances of that class,
or in other words, objects. This way a whole new design for a transmission does not need
to be created for each type of auto, but rather just a different variation. The same applies to
software, where a whole new complete design does not need to be created but just a
different version of the original class. Although this is just a brief glimpse of objects, this
same idea can be applied to software and a more complete discussion will be presented in
Chapter 2.
Unified Modeling Language (UML) is a visual method used to help contruct a program
using classes and objects. One might ask since Java is an Object Oriented (OO) language
and UML is helpful in creating an OO program, why would one need pseuodocode? The
answer is because each class and instance of a class or object contains code, pseudocode
can help with the design of the class. So whereas UML helps with the creating of classes
and objects, pseudocode helps with the creation of code within classes and objects. UML
will be discussed further in Section 2.10.
12 0 Introduction to Computing Concepts

0.4.3.3 Debugging
Even when all attempts to write a logically correct program are followed, the possibility of
logic errors still exists. The process of finding and fixing logic errors is known as
debugging. When trying to debug a program, a programmer should not start to randomly
alter code in the hope that the error might be fixed. Although this might work occasionally
with smaller programs, it rarely works as programs become larger and more complex.
Instead, one should look for patterns in the output in an attempt to isolate the problem.
Further, one needs to carefully check the program by walking through the code to ensure
that it is doing what was originally intended.
To assist in this process many Integrated Development Environments (IDEs), which are
used to enter, edit, compile, and execute a program, sometimes include debuggers that can
trace the contents of various memory locations to help locate a logic error. However, do
not rely on the debugger alone to help correct the problem, but rather use it as a tool to
assist in tracing the logic of the program. If a debugger is not available, well-placed output
statements at critical points in the program can help in the debugging process. In the end,
it is the programmer reading the code carefully to see what the code is actually doing, rather
than what one thinks it is doing, that will ultimately fix logic errors in a program. [9]

0.5 A Brief Look at Computer Ethics

As one is just learning to write code in a programming language, there is a tendency to be


preoccupied with getting programs to work correctly. However, at the same time when
acquiring a lot of technical knowledge, it is also important to learn what is needed to
enter the computing profession. This includes, but is not limited to knowledge of various
ethical issues concerning property, privacy, and responsibility.
Initially one might not think this is important since they are just a beginner and not
working for a major company. Although this may not seem initially significant, these
issues become increasingly even more important as one rapidly gains new knowledge,
even during a course of a semester.
For example, when beginning programmers are working on their own individual
programming assignments in a classroom environment, they will often be turned in for a
JUDGH$VVXPLQJLWLVQRWDJURXSSURJUDPPLQJDVVLJQPHQWHDFKVWXGHQW¶VSURJUDPLV
considered to be their own property whether it is on paper or on a file in a computer. If
RQHVWXGHQWKDVDFFHVVWRDQRWKHUVWXGHQW¶VSURJUDPWKHQWKLVFRXOGbe a concern of
intellectual property rights.
In another example, one might have the opportunity to work in the Information
Technology (IT) department at the school, college, or university. This might entail
ZRUNLQJRQDQRWKHUVWXGHQW¶VVWDIIPHPEHU¶VRU IDFXOW\PHPEHU¶VFRPSXWHU,QGRLQJ
so, one might have access to programs and files that have sensitive information which
would concern the privacy of others.
Also, consider the possibility that after completing a year or two of coursework, one
might have the opportunity to work on an internship writing programs for a company.
Then the programs are no longer merely submitted for a grade but are integral to the
operation of that company. Mistakes are no longer just points taken off for a grade, but
could haYHDQLPSDFWRQILQDQFLDOPDWWHUVDQGDIIHFWSHRSOH¶VOLYHV7KHUHVXOWLVWKDWWKH
0.5 A Brief Look at Computer Ethics 13

testing and correct operation of a program is imperative and is the responsibility of the
programmers.
The field that includes these instances and other related issues is known as ethics. Entire
stand-alone courses are offered, typically from the philosophy department, and
corresponding books have been written that address the many theories and the application
of those theories to specific instances. In addition, these ethical theories have been
applied to paticular areas such as business ethics, medical ethics, environmental ethics as
well as computer ethics. With respect to the latter, many colleges offer separate courses
in computer ethics that may be given as an elective or may be required for a major in
computer science.
Since entire books have also been written on the field of computer ethics it would not be
possible to discuss all the theories here. Fortunately, various professional organizations in
many different fields provide codes of ethics. The same is true in the field of computing
where the Institute of Electrical and Electronics Engineers (IEEE) Computer Society[3]
and the Association of Computing Machinery (ACM) [1] have each developed a Code of
Ethics. These codes help provide guidance when confronting various ethical situations
within the world of computing.
These codes are provided by their respective organizations and are available online. The
reader is encouraged to look at least one of these codes as possLEO\LQGLFDWHGE\RQH¶V
instructor. It might also prove interesting to look at both codes to see the similarities and
possible differences between them.
After examining a code of ethics such as the ACM Code of Ethics, there are some
exercises at the end of the chapter based on the discussion at the beginning of this section
that can serve either as a discussion in the classroom or as an essay question in a
homework assignment. Although it is beyond the scope of this text to examine the
theories and codes in any detail, there are a number of texts that examine theories and
LVVXHVLQPRUHGHWDLOVXFKDV³(WKLFVLQ&RPSXWLQJ$&RQFLVH0RGXOH´E\-RVHSK0LJJD
Kizza. [5]

0.6 Summary
‡ Machine language and assembly language are low-level languages, where the former
uses ones and zeros and the latter uses mnemonics.
‡ High-level languages are more English-like, where C, C++, and Java are examples of
high-level languages.
‡ Compilers convert the entire high-level language program into machine language
before executing the machine language program, whereas interpreters convert a high-
level language program one instruction at a time and then execute only the
corresponding machine language instructions before converting the next high-level
instruction.
‡ Java is a hybrid system, where the Java instructions are converted into an intermediate
language called bytecode using a compiler and then the bytecode is converted into
machine language using an interpreter.
‡ Computational thinking is a problem-solving process that includes decomposition,
pattern recognition, abstraction, algorithms, and logical thinking. The above are skills
that you can apply in life in general.
14 0 Introduction to Computing Concepts

‡ Even if one is just beginning in the field of computing, it is important to understand


professional obligations.
‡ Three important areas of computer ethics include but are not limited to property,
privacy, and responsibility,
‡ Two prominent professional Codes of Ethics are provided by the IEEE Computer
Society and the ACM.
0.7 Exercises (Items Marked with an * Have Solutions in Appendix E )
1. A River Crossing puzzle involves a famer crossing a river with a wolf, a goat, and
a cabbage on the way home. After the famer bought them at the market, he rented
a boat to cross the river. The farmer could take only one of his purchases with
him, the wolf, the goat, or the cabbage, when taking the boat. If a wolf, a goat,
and cabbage are left unattended together, the wolf would eat the goat, or the goat
would eat the cabbage. The farmer's challenge is to bring himself and his
purchases to the other side of the river, leaving each purchase intact. After solving
the problem discuss how the computational thinking concepts, decomposition,
pattern recognition, abstraction, algorithm, and logical thinking, were used to
come up with the answer.

2. Sudoku is a number-placement puzzle. In original Sudoku, the objective is to fill a


9 × 9 grid with numbers so that each column, each row, and each of the nine 3 × 3
sub-grids contain all the numbers from 1 to 9. Discuss how the computational
thinking concepts, decomposition, pattern recognition, abstraction, algorithm, and
logical thinking, could be used to solve the puzzle.

3. Compare the two codes of ethics mentioned previously in Section 0.5. Identify
one or more elements that are similar. If possible, identify one element that
appears in one code but does not seem to appear in the other.

4. Using one of the code of ethics such as the ACM Code of Ethics, or the code
assigned by the instructor, analyze the following scenarios as to the proper course
of action. Be sure to indicate which element in the code applies.

a. A student in a first-year course has asked a fellow student for assistance with
their programming assignment. After starting to look over the program for the
SRWHQWLDOHUURUWKHVWXGHQWVHHNLQJDVVLVWDQFHVD\V³7KLVLVVXUHWDNLQJDORWRI
time. Might it be easier to just send me a copy of the file containing your
SURJUDPDQG,FDQMXVWFKDQJHWKHQDPHDWWKHWRS"´$FFRUGLQJWRWKHFRGHRI
ethics selected or assigned, what should the student who is providing the
assistance do? What alternatives are there?

b. A student is working in the Information Technology department and has been


asked to work on a faculty members personal computer to install a new
version of a software package. In the process, the student sees the spreadsheet
FRQWDLQLQJWKHJUDGHVIRUWKHSURIHVVRU¶VFODVVHV7KLQNLQg that it will cause
Discovering Diverse Content Through
Random Scribd Documents
Torarin näki selvästi harmaisiin puetun neidon hiipivän sir Archien
jälessä, mutta sir Archie ei häntä nähnyt. Kun hän kääntyi ympäri,
niin neito seisahti paikalleen ja sir Archien oma leveä varjo pimensi
hänet kokonaan.

Sir Archie kääntyi heti takasin ja jatkoi kulkuaan, ja silloin neito


taas kiireesti läheni häntä ja näytti kuiskuttavan hänen korvaansa.

Mutta tätä näkyä Torarin ei jaksanut sen kauempaa kestää. Hän


kiljasi kovasti ja ruoski hevostaan ja ajoi täyttä karkua, hevonen
Valkosessa vaahdossa, pirttinsä ovelle asti.

Vaino.

1.

Marstrandin kaupungin asuttu osa oli rannikon puolella pientä


saarta, missä sataman suojana oli kihermä luotoja ja saaria. Siellä
olivat kadut ja kujat väkeä täynnä, rannassa oli veneitä ja laivoja
kylki kylessä, siellä suolattiin silliä, perattiin kaloja, sillä puolella oli
kirkko ja hautuumaa, raatihuone ja tori, ja siellä kasvoi korkeita
lehtipuita, jotka kesäaikana antoivat väriä kaupungille.

Mutta Marstrandinsaaren länsiosassa, jolla ei ollut yhtään saarta


eikä luotoa suojana aukeata merta vastaan, siellä ei ollut muuta kuin
paljaita louhikkoja ja aaltojen uurtamia kallioisia niemenkärkiä. Maa
kasvoi ruskeahelpeistä kanervikkoa ja piikkisiä orjantappuroita, siellä
täällä oli saukon ja ketun koloja tai haahkan ja kalalokin pesiä, mutta
polkuja ja taloja ja ihmisasukkaita ei missään näkynyt.
Vaan Torarinin mökki seisoi keskellä saarta korkealla mäellä, niin
että kaupunki oli sen toisella ja autio korpi toisella puolen, ja kun
Elsa neito avasi mökin oven ja nousi kalliolle, niin hän näki siitä
länteenpäin siihen mustaan reunaan asti mistä sula meri alkoi.

Ja kaikki ne merimiehet ja kalastajat, jotka olivat jäiden sulkemina


Marstrandissa, kulkivat usein Torarinin mökin ohi käydäkseen mäeltä
katsomassa, eivätkö lahdet ja salmet vielä olleet päässeet vapaiksi
jääpeitteestään.

Elsa neito seisoi usein mökin kynnyksellä katselemassa


sivukulkijoita.
Hänen sydämensä sairasti yhä äskeistä suurta suruaan, ja hän
ajatteli:
Minusta ne ovat onnellisia ne kaikki, joilla on jotakin ikävöitävää.
Vaan itselläni ei ole mitään kaihottavaa koko maailmassa.

Yhtenä iltana Elsa näki kalliolla pitkän, töyhtöhattuisen miehen,


joka katseli länteen merelle päin samoinkuin kaikki muutkin. Ja Elsa
neiti huomasi oitis, että mies oli sir Archie, skottilaisten päällikkö,
sama jonka kanssa hän oli laiturilla jutellut.

Kun sir Archie kaupunkiin palatessaan kulki mökin ohi, seisoi Elsa
neiti yhä edelleen kynnyksellä, ja hän itki.

»Mikä sinua itkettää, neito?» kysyi sir Archie, seisahtuen hänen


eteensä.

»Sitä itken, kun ei minulla ole mitään kaihottavaa», sanoi Elsa.


»Kun näin teidän seisovan kalliolla ikävissänne, niin minä ajattelin:
»varmaan hänellä on meren tuolla puolen koti, jonne hän nyt
matkustaa.»
Silloin sir Archien sydän heltyi, niin että hän sanoi: »Nyt ei
vuosikausiin kukaan ole minulle puhunut kodistani. Luoja ties miten
isäni talossa nyt voitanee. Neljätoista vuotiaana sieltä lähdin
vieraissa sotajoukoissa palvelemaan.»

Sitte sir Archie tuli Elsan luokse huoneeseen ja rupesi hänelle


puhelemaan kodistaan.

Ja Elsa istui ääneti, kuunnellen sir Archien pitkää ja kaunista


puhetta. Hän oli onnellinen joka sanasta mitä sir Archielta kuuli.

Vaan kun sir Archie nousi lähteäkseen pois, niin hän pyysi saada
suudella Elsaa.

Silloin Elsa kielsi sen ja lähti ovelle pakoon, mutta sir Archie
asettui eteen ja yritti suudella väkisin.

Mutta samassa mökin ovi aukeni ja emäntä tuli hyvin kiireesti


sisään.

Silloin sir Archie väistyi Elsan luota. Hän ojensi hänelle vaan
kätensä hyvästiksi ja riensi pois.

Vaan Torarinin äiti sanoi Elsalle: »Oikein teit, kun lähetit minua
noutamaan. Ei nuoren neidon ole hyvä olla kahden kesken sellaisen
miehen kuin sir Archien kanssa. Kyllähän tiedät, Elsa, että
palkkasoturit ovat armotonta väkeä, eikä niillä ole Jumalasta tietoa.»

»Minäkö olisin lähettänyt teitä kutsumaan?» Elsa sanoi


ihmeissään.

»Niin», vastasi emäntä, »seisoin juuri laiturilla työssä, kun ihan


ventovieras neitonen tuli tuomaan terveisiä, että sinä kaipasit minua
kotiin.»

»Minkänäköinen neito se oli?» Elsa sanoi.

»En tullut häntä niin tarkastaneeksi, että osaisin kuvata», sanoi


eukko. »Mutta sen verran huomasin, että hänellä oli ihmeen kevyt
käynti, kun ei lumi alla ensinkään narahtanut.»

Kun Elsa kuuli tämän, niin hän aivan kalpeni ja sanoi: »Silloin se
on varmaankin ollut taivaan enkeleitä, joka teille toi sanan ja lähetti
teidät kotiin.»

2.

Kerran sir Archie tuli uudestaan Torarinin mökkiin puhelemaan


Elsan kanssa.

He olivat kahden kesken. He keskustelivat rattosasti ja


kummallakin oli hauska.

Sir Archie esitti Elsalle, että hän lähtisi hänen mukanaan


Skotlantiin. Siellä hän lupasi rakentaa Elsalle linnan, niin että
hänestä tulisi rikas hovinrouva. Hän sanoi antavansa hänelle satoja
käskyläisneitoja ja tanssittavansa kuninkaan hovipidoissa.

Elsa istui ääneti ja kuunteli joka sanaa minkä sir Archie virkkoi, ja
hän uskoi ne tosiksi. Ja sir Archie ajatteli, ettei ikinä ollut tavannut
niin helposti lumottavaa neitoa.

Yhtäkkiä sir Archie kävi äänettömäksi ja alkoi katsella vasenta


kättään.

»Mikä teille tuli, sir Archie, miksette puhu enää?» kysyi Elsa.
Sir Archie aukoi ja sulki kättään ikäänkuin suonenvedossa.

»Mitä se on, sir Archie?» Elsa kysyi. »Onko teillä kipuja


kädessänne?»

Silloin sir Archie kääntyi hirmustuneen näköisenä häneen päin ja


sanoi: »Näetkö tuota hiusta, Elsa, joka kiertyy käteni ympäri? Näetkö
tuota vaaleata hiuskutria?»

Kun hän rupesi siitä puhumaan, ei neitonen nähnyt, mutta lopulta


hän jo näki hienon, vaalean hiuskiehkuran solmeutuvan sir Archien
käden ympäri.

Ja Elsa neiti kavahti säikähtyneenä ylös ja huusi: »Sir Archie,


kenen se on se hius joka on kätenne ympärillä?»

Sir Archie katsahti häneen neuvottomana. »Sen kyllä tunnen, Elsa


neiti, että se on oikea hius. Se tuntuu lahealta ja vilposelta ihoa
vasten. Mutta mistä se on tullut?»

Neitonen katsoi käteen oudosti tuijottavin silmin.

»Juuri tuollalailla kasvinsisareni tukka kiertyi sen miehen käteen,


joka hänet surmasi.»

Silloin sir Archie väkinäisesti naurahti, mutta vetäsi äkkiä kätensä


pois.

»Kas, Elsa», hän sanoi, »me molemmat säikymme yhtä herkästi


kuin pikkulapset. Nyt se on poissa. Se ei ollutkaan muuta kuin
ikkunasta eksynyt auringonsäde.»
Mutta Elsa neiti hyrähti katkeraan itkuun ja sanoi: »Nyt olen taas
makaavinani uunilla ja kuulevinäni murhamiesten tekevän työtään.
Voi voi, minä toivoin viimeiseen asti, etteivät he löytäisi rakasta
kasvinsisartani, mutta silloin yksi heistä tuli ja veti hänet uunilta alas,
ja kun hän koetti paeta, niin mies kiersi hänen tukkansa kätensä
ympärille ja pidätti häntä. Vaan hän makasi polvillaan miehen edessä
ja sanoi: 'Katso minun nuoruuttani! Anna minun jäädä eloon, jotta
vielä ehtisin oppia, mitä varten olen maailmaan tullut. En ole sinulle
tehnyt mitään pahaa, miksi sinä siis tahdot minut surmata? Miksi
sinä kiellät minun elämästä?’ Ja mies ei kuunnellut häntä, vaan
surmasi hänet.»

Sir Archie ei mitään virkkanut. Hän seisoi silmäkulmat rypyssä ja


katsoi syrjään.

»Niin, oi kun kerran tapaisin sen miehen!» Elsa sanoi. Hän seisoi
nyrkkiään puristaen sir Archien edessä.

»Et voi tavata sitä miestä», sanoi sir Archie. »Hän on kuollut.»

Mutta neitonen heittäytyi lavitsalle itkeä nyyhkyttämään. »Sir


Archie, sir Archie, miksi johditte ne vainajat mieleeni? Nyt minun
täytyy itkeä koko tämä ilta ja yö. Menkää pois, pois, sir Archie, sillä
nyt minä en voi muuta ajatella kuin vainajia. Nyt minä vaan muistelen
kasvinsisartani, joka minulle oli niin armas.»

Eikä sir Archie kyennyt häntä lohduttamaan, vaan hänen täytyi


lähteä kyyneleitä ja valituksia pakoon, ja hän meni juomaveikkojensa
luo.

3.
Sir Archie ei voinut käsittää, miksi hänen mielensä aina oli täynnä
synkkiä ajatuksia. Niistä hän ei päässyt vapaaksi silloin kun Elsan
kanssa puheli, eikä silloin kun istui tovereineen juomassa. Vaikka
hän usein tanssi yökaudet ranta-aitoissa, eivät ne hänestä eronneet,
eikä hän saanut niistä rauhaa edes samoillessaan peninkulmien
päähän jäätyneelle merelle.

»Miksi minun täytyy alati muistaa sitä, jota en tahdo ajatella?»


puheli sir Archie itsekseen. »On aivan kuin joku minua aina seuraisi
ja kuiskuttaisi korvaani.»

»On aivan kuin joku kiertäisi verkkoa ympärilleni, sitoakseen kaikki


ajatukseni tähän yhteen ainoaan», sanoi sir Archie. »En voi nähdä
metsästäjää, joka verkkoa kiertää, mutta hänen hiiviskelevät
askelensa kuulen jälessäni.»

»On aivan kuin maalari minun edelläni kulkisi muuttamassa


samaksi kuvaksi kaikki mihin katson», sanoi sir Archie. »Jos
käännän silmäni taivaalle tai maahan, niin en kohtaa muuta kuin
saman näyn.»

»On aivan kuin kivenhakkaaja istuisi sydämelläni takomassa


siihen yhtä ainaista surua», sanoi sir Archie. »En voi nähdä sitä
kivenhakkaajaa, mutta yöt päivät tunnen selvästi hänen moukarinsa
iskut. Sinä kivisydän, sinä kivisydän, hän sanoo, nyt sinun täytyy
alistua, nyt minä takomalla taon sinuun surun.»

Sir Archiella oli kaksi ystävää, sir Reginald ja sir Filip, jotka alati
olivat hänen seurassaan. Häntä suretti, kun hän oli pahalla tuulella
eikä mistään tuntenut itseään onnelliseksi.
»Mikä sinua oikein vaivaa?» he usein sanoivat. »Miksi sinun
silmiäsi niin kuumottaa ja poskesi käyvät niin kalpeiksi?»

Sir Archie ei tahtonut sanoa heille mikä häntä kiusasi. Hän ajatteli:
Mitä he minusta sanoisivatkaan, jos huomaisivat heittäytyneeni näin
miehuuttomaksi? He eivät minua enää tottelisi, jos kuulisivat minun
ruvenneen katumaan tekoa, joka oli välttämätön.

Kun he häntä yhä enemmän pakottivat, niin hän lopulta sanoi


johtaakseen heidät harhaan:

»On tuntunut niin kummalta näinä päivinä. Olen tavannut erään


neidon, jota mieleni halaa, mutta en vaan häntä saavuta. Aina on
joku este sattunut tielleni.»

»Kenties neito sitten ei sinua rakasta», sanoi sir Reginald.

»Kyllä uskon hänen mielensä minuun taipuvan», sir Archie sanoi,


»mutta hänellä on joku vartija, joka estää minun häntä
saavuttamasta.»

Silloin sir Reginald ja sir Filip purskahtivat nauruun ja sanoivat:


»Sen neitosen kyllä me sinulle toimitamme.»

Illalla Elsa käveli yksinään kujaa pitkin mäelle päin. Hän tuli
väsyneenä työstään ja ajatteli itsekseen: Tämä elämä on työlästä,
enkä minä siitä saa yhtään iloa. Minua ilettää koko päivän seista
siellä laiturilla kalanhajussa. Minua ilettää kuulla niiden naisten tylyllä
äänellä laskevan leikkiä ja nauravan. Minua ilettää nähdä ahnasten
lokkien kärkkyvän pöytien ympärillä siepatakseen kalapaloja läpi
käsieni. Kunpa edes joku tahtoisi tulla viemään minut pois täältä!
Silloin minä häntä seuraisin vaikka maailman ääreen.
Elsa kulki juuri kujan pimeintä kohtaa, kun sir Reginald ja sir Filip
astuivat varjosta hänen luokseen ja tervehtivät häntä.

»Elsa neiti», he sanoivat, »me tuomme sinulle sanan sir Archielta.


Hän makaa sairaana majatalossa. Hän ikävöi kovin saada puhella
sinun kanssasi ja pyytää, että lähtisit mukaamme häntä katsomaan.»

Elsa hätääntyi kuullessaan että sir Archie oli niin huonona


sairaana, ja kääntyi oitis seuraamaan skottilaisia herroja, jotka
tahtoivat saattaa hänet majataloon.

Sir Filip ja sir Reginald kulkivat toinen toisella puolen häntä. He


hymyilivät keskenään ja ajattelivat, ettei mikään voinut olla
helpompaa kuin Elsan viekotteleminen.

Elsa neidillä oli kova kiire. Hän melkein juoksi kujaa alamäkeen.
Sir Filip ja sir Reginald saivat käydä rivakasti pysyäkseen hänen
rinnallaan.

Mutta Elsa neidin kulkiessa näin kiireisesti alkoi jotakin vieriä


hänen jalkansa edessä. Kaiketi se heitettiin hänen tielleen, ja hän oli
siihen vähällä kompastua.

»Mitä se on se joka jalkaini edessä hyrrää?» Elsa ajatteli. »Kaiketi


olen potkassut maasta kiven, joka nyt vierii kujan rinnettä alas.»

Hänellä oli niin kiire sir Archien luo, ettei joutanut välittämään siitä
mikä ihan varpaittensa edessä vieri. Hän potkasi sen syrjään, mutta
se palasi heti ja kieri hänen edessään alas kujaa pitkin.

Elsa kuuli sen helähtävän hopealta, kun hän sitä potkasi, ja hän
näki sen välkkyvän ja kimaltelevan.
»Ei se olekkaan tavallinen kivi», Elsa ajatteli. »Luulenpa että se on
hopearaha.» Mutta hänellä oli niin kiire sir Archien luo, ettei katsonut
ehtivänsä nostaa sitä maasta.

Mutta yhä edelleen se vieri hänen jalkainsa edessä, ja hän ajatteli:


Sinä ennätät pikemmin, jos sieppaat tuon pois tieltäsi. Voithan
viskata sen kauvas pois, jollei se mitään ole.

Hän kumartui ja otti sen maasta. Se oli suuri pyöreä raha, joka kiilti
Valkoselta hänen kädessään.

»Minkä sinä siitä kadulta löysit, neiti?» kysyi sir Filip. »Se kiiltää
niin valkealta kuutamossa.»

He kulkivat juuri suuren ranta-aitan ohi, jommoisissa vieraat


kalastajat asuivat ollessaan pyyntimatkoilla Marstrandissa. Oven
päällä riippui sarvilyhty, josta hiukan valoa tuikki kadulle.

»Katsotaas nyt mitä sinä kadulta löysit, neiti», sanoi sir Reginald,
pysähtyen lyhdyn alle.

Elsa ojensi rahan valoa kohti, ja tuskin ennätettyään siihen


katsahtaa hän rupesi huutamaan: »Tämä on Aarne herran rahoja!
Minä tunnen sen. Tämä on Aarne herran rahoja!»

»Mitä nyt sanotkaan, neiti?» kysyi sir Filip. »Minkätähden sanot


tätä
Aarne herran rahaksi?»

»Minä tunnen sen», sanoi Elsa. »Olen monesti nähnyt Aarne


herran pitävän sitä kädessään. Totisesti tämä on Aarne herran
rahoja.»
»Älä huuda niin kovasti, neito!» sanoi sir Filip. »Kaikki ihmiset
tänne rientävät utelemaan, mitä se kirkuminen on.»

Mutta Elsa ei kuunnellut sir Filipin puhetta. Hän näki ranta-aitan


oven olevan auki. Keskellä permantoa paloi pystyvalkea, jonka
ympärillä joukko miehiä istui hitaasti ja tyynesti jutellen.

Elsa neiti hyökkäsi sisään heidän luokseen. Hän piti rahaa ylhäällä
kädessään.

»Hoi, kuulkaa miehet», hän huusi, »nyt tiedän, että Aarne herran
murhaajat ovat elossa. Kas tässä on Aarne herran raha, jonka
löysin!»

Kaikki miehet kääntyivät häneen päin. Hän näki silloin Torarinin,


kalakauppiaan, istuvan joukossa.

»Mitä nyt tuletkaan huutamaan, neito?» kysyi Torarin silloin.


»Kuinka voit erottaa Aarne herran rahat muista?»

»Erotan toki tämän mistä muusta tahansa», Elsa sanoi. »Se on


vanha ja iso, ja siinä on lovi reunassa. Aarne herra sanoi sen olevan
vanhojen Norjan kuningasten ajoilta, eikä hän sitä koskaan käyttänyt
ostoksiin.»

»No kerrohan, neito, mistä sen löysit», sanoi muuan toinen


kalastaja.

»Löysin sen kadulta, kierimästä jalkaini edessä», Elsa sanoi.


»Sinne se on varmaan murhaajilta pudonnut.»

»Olkoon nyt totta tai lorua mitä puhut», sanoi Torarin, »niin mitä
me voimme tehdä? Emme me siltä voi murhamiehiä löytää, vaikka
sinä tiedätkin heidän kulkeneen yhtä kaupunkimme katua.»

Kalastajain mielestä Torarin oli puhunut järkevästi. He istahtivat


äskeisille paikoilleen pystyvalkean ääreen.

»Tule pois, Elsa, mukaani kotiin!» Torarin sanoi. »Ei nyt ole aika
neitosen juoksennella katuja ja kujia.»

Kun Torarin tätä puhui, niin Elsa kääntyi katsomaan äskeisiä


saattajiaan. Mutta sir Reginald ja sir Filip olivat hiipineet tiehensä
hänen huomaamattaan.

Raatikellarissa.

1.

Marstrandin raatikellarin emäntä avasi yhtenä aamuna ovet,


portaita ja eteistä lakaistakseen. Hän näki silloin nuoren neidon
istuvan portailla odottamassa. Hänellä oli yllään kaitanen harmaa
hame, joka oli vyötäisiltä solkinauhalla sitaistu. Vaalea tukka ei ollut
sykeröllä eikä palmikoituna, vaan suoraan riipuksissa kasvojen
molemmin puolin.

Oven auetessa hän nousi istuiltaan ja astui portaita myöten


emännän luokse. Vaan emännästä se oli kuin unissakulkijan käyntiä.
Hän piti silmiään puoliummessa ja käsivarsiaan kylkiä pitkin
likistettyinä. Kuta lähemmäs hän tuli, sitä enemmän emäntä ihmetteli
hänen jäsentensä hentoutta. Hänen kasvonsakin olivat kauniit, Mutta
ne olivat niin ohuet ja läpikuultavat kuin olisivat olleet haurasta lasia.
Emännän luo tultuaan hän kysyi, olisiko talossa ollut hänelle
sopivaa tointa. Hän olisi tahtonut päästä palvelukseen.

Mutta emäntä ajatteli kaikkia niitä hurjia miehiä, jotka iltasin


istuivat juomassa olutta ja viiniä hänen kellarissaan, eikä hän voinut
olla hymyilemättä. »Ei täällä meidän talossa ole paikkaa noin
pienelle neidolle», hän sanoi.

Neitonen ei nostanut silmiään eikä muuten mitenkään liikahtanut,


hän vaan uudisti pyyntönsä päästä emännän luo palvelukseen. Hän
ei sanonut pyytävänsä ruokaa eikä palkkaa, ei mitään muuta kuin
jotakin tointa.

»Jos oma tyttäreni olisi sellainen kuin sinä», emäntä sanoi, »niin
antaisin saman kiellon. Suon sinulle parempaa kuin palveluspaikan
minun luonani.»

Silloin neitonen kääntyi hitaasti nousemaan portaita ylös, ja


emäntä jäi katsomaan hänen jälkeensä. Tyttö oli hänestä niin pienen
ja avuttoman näköinen, että häntä tuli vallan sääli.

Emäntä huusi hänet takasin ja sanoi hänelle: »Ehkäpä sinun


sentään on turvattomampaa yksin maleksia satamassa ja torilla kuin
olla täällä minun luonani. Saat nyt täksi päiväksi jäädä tänne kuppeja
ja lautasia pesemään, niin nähdään mihin kykenet.»

Emäntä vei hänet pieneen huoneeseen kellarisalin vieressä. Se ei


ollut suurempi kuin joku seinäkomero. Siinä ei ollut mitään lakeista
eikä ikkunaa, vaan ainoa valo tuli kapakkahuoneeseen aukeavasta
seinäluukusta.
»Seiso täällä nyt», hän sanoi neitoselle, »ja huuhdo kaikki kupit ja
lautaset, joita sinulle tuosta luukusta ojennan. Sittenpähän näen
voinko sinua palveluksessa pitää.»

Neitonen meni komeroon ja liikkui siellä niin hiljaa, että emännästä


tuntui kuin olisi kuollut hautaansa puikahtanut.

Hän seisoi siellä sisällä koko päivän eikä kenenkään kanssa


sanaa vaihtanut eikä luukusta ulos kurkistellut, vaikka
kapakkahuoneessa väkeä liikehti lakkaamatta. Eikä hän huolinut
ruuasta, kun sitä hänelle tarjottiin.

Hänen ei kuultu kalisuttavan astioita, mutta milloin hyvänsä


emäntä ojensi kätensä luukulle, niin aina siinä oli tarjolla
vastahuuhdottuja vateja, joissa ei täplääkään näkynyt.

Mutta kun hän rupesi niitä käsissään nostamaan pöydille, niin ne


olivat niin kylmiä, että melkein tuntuivat vievän nahan sormista.
Emäntää värisytti ja hän sanoi: »On aivan kuin ne ottaisin kylmän
kuoleman käsistä.»

2.

Yhtenä päivänä ei laitureilla ollut työtä saatavissa. Elsa istui


kotona Torarinin mökissä ja kehräsi. Pesävalkea paloi virkeästi ja
valaisi joka kolkan pirtissä.

Kesken työnsä Elsa tunsi kasvoillaan kylmän henkäyksen,


ikäänkuin olisi ovi ollut raollaan. Hän katsahti ylös ja näki kuolleen
kasvinsisarensa seisovan edessään lattialla.
Elsa seisautti kädellään värttinän pyörimisen ja istui sitte hiljaa,
tuijottaen kasvinsisareensa. Ensi hetkenä hän säikähti, mutta heti
senjälkeen ajatteli: »Eihän minun sovi pelästyä omaa
kasvinsisartani. Oli hän kuollut tai elävä, niin aina minä iloitsen kun
saan häntä nähdä.»

»Sisko kulta», hän sanoi vainajalle, »haluatko minulta jotakin?»

Toinen silloin matalalla, kuiskaavalla äänellä vastasi: »Elsa


sisareni, olen mennyt ravintolaan palvelukseen, ja emäntä on minun
antanut kaiken päivää seista huuhtomassa kuppeja ja lautasia. Nyt
illalla minä olen niin väsyksissä, etten enempää jaksa. Olen nyt tullut
pyytämään, että sinä lähtisit sinne avukseni.»

Silloin Elsasta tuntui kuin olisi hänen järkensä sumennut. Hän ei


kyennyt enää ajattelemaan eikä tahtomaan eikä pelkäämään. Hän
tunsi vaan suurta iloa siitä, että kasvinsisarensa oli palannut hänen
luokseen, ja vastasi: »Kyllä, sisko kulta, heti lähden sinua
auttamaan.»

Silloin kuollut kääntyi ovelle menemään, ja Elsa kulki hänen


jälessään. Mutta kynnyksellä seistessään hänen kasvinsisarensa
pysähtyi ja sanoi Elsalle: »Käy ottamassa vaippa yllesi. Ulkona on
kova myrsky.» Näitä sanoja virkkaessa hänen äänensä kuului vähän
selvemmin ja siinä oli hiukan sointuakin.

Elsa otti seinältä vaippansa ja kääri sen ympärilleen. Hän ajatteli


itsekseen: Vielähän kasvinsisareni minua rakastaa, ei hän mitään
pahaa aio. Minusta on vaan onnellista saada seurata häntä mihin
tahansa hän minut vie.
Sitten hän kuolleen seurassa lähti Torarinin mökiltä kulkemaan
jyrkästi viettävää kujaa pitkin sataman ja torin puoleiseen
uudempaan kaupunkiin.

Kuollut astui kaiken aikaa Elsasta kahta askelta edellä. Sinä iltana
oli kova myrsky, joka kapeissa kujasissa oli pusertaa kulkijan seinää
vasten, ja Elsa huomasi, että pahimpien puuskien aikana kuollut
asettui hänen ja tuulen väliin, suojelemaan häntä minkä hennolla
ruumiillaan voi.

Vihdoin saavuttuaan raatihuoneelle kuollut astui kellariportaita alas


ja viittasi Elsaa seuraamaan. Mutta ovea avatessa tuulen vihuri
sammutti kynttilän eteisen lyhdystä, joten he jäivät pimeään. Silloin
Elsa ei olisi tiennyt kääntyä minnekkään päin, jollei kuollut olisi
tarttunut hänen käteensä ruvetakseen häntä taluttamaan. Mutta
kuolleen käsi oli niin kylmä, että Elsa säpsähti ja kauhu alkoi häntä
puistattaa. Kuollut silloin veti kätensä pois ja kääri sen Elsan vaipan
liepeeseen, ennenkuin talutti häntä edelleen. Mutta Elsa tunsi
kylmän väreitä vielä vuorin ja turkiksien läpi.

Kuollut ohjasi nyt Elsaa pimeän käytävän kautta ja avasi sitte


hänelle oven. He tulivat pimeään komeroon, johon hiukan valoa
pilkotti seinässä olevasta luukusta. Elsa näki tulleensa siihen
huoneeseen, jossa ravintolan palvelustyttö seisoi pesemässä
kuppeja ja lautasia, ennenkuin ne pantiin vierasten eteen. Elsa näki
vesisoikon häämöttävän lattialla ja luukussa joukon huuhdottavaksi
siihen pantuja juomalaseja ja astioita.

»Tahdotko, Elsa, nyt tämän yön olla minun apunani?» kuollut


kysyi.
»Sisko kulta», sanoi Elsa, »tiedäthän että tahdon sinua auttaa
missä hyvänsä minua tarvitset.»

Samalla Elsa jo heitti vaipan päältään. Hän kääri hihansa ylös ja


rupesi työhön.

»Tahdotko, Elsa, nyt olla täällä hyvin ääneti, jottei emäntä huomaa
minun hankkineen apulaista?»

»Sisko kulta», Elsa sanoi, »koetan minkä suinkin voin.»

»No hyvästi sitten, Elsa», sanoi kuollut. »Nyt pyydän sinulta vaan
yhtä. Ja se on, ettet tämän jälkeen minuun ylen kovasti suutu.»

»Mitä varten sinä minulle hyvästejä heität?» Elsa kysyi. »Tulenhan


mielelläni joka ilta sinun avuksesi.»

»En pyydä sinua olemaan kuin tämän illan», sanoi kuollut.


»Luultavasti sinä nyt autatkin minua niin, että saan tämän toimen
päätetyksi.»

Kun tätä puheltiin, oli Elsa jo kyyristynyt työhönsä. Kaikki oli


hetken hiljaa, mutta sitte hän tunsi otsallaan samallaisen
henkäyksen kuin kuolleen tullessa kalastajamökkiin hänen luokseen.
Hän katsahti silloin ylös ja näki olevansa yksin. Hän tiesi nyt, mikä
hänen otsallaan oli tuntunut kylmältä henkäykseltä, ja sanoi
itsekseen: »Kuollut kasvinsisareni suuteli minua otsalle, ennenkuin
lähti pois luotani.»

Elsa teki nyt ensin työnsä valmiiksi. Hän huuhtoi kaikki maljat ja
kannut ja kuivasi ne. Sitte hän meni luukulta katsomaan, oliko sinne
pantu mitään lisää. Kun ei siellä mitään ollut, niin hän jäi luukun
ääreen seisomaan katsellen kellarisaliin.
Oli sellainen aika päivästä, jolloin ei ketään vieraita tavannut
kellariin tulla. Emäntä ei ollut istumassa pöytänsä takana eikä hänen
palvelijoitaan ollut saapuvilla. Ketään muuta huoneessa ei näkynyt
kuin kolme miestä, jotka istuivat suuren pöydän päässä. He olivat
vieraita, vaan tuntuivat liikkuvan kuin kotonaan, koska muuankin
heistä joka oli juonut maljansa pohjaan, ilman muut? kävi
täyttämässä sen suuresta viiniruukusta ja istahti sitte uudestaan
juomaan.

Elsa tunsi olevansa kuin vastatullut jostain vieraasta maailmasta.


Hänen ajatuksensa olivat kuolleessa kasvinsisaressaan, niin ettei
hän oikein kyennyt tajuamaan mitä näki. Vasta pitkän ajan päästä
hänelle selvisi, että nuo pöydän ääressä istuvat miehet olivat hänelle
tuttuja ja rakkaita. Sillä nehän olivat sir Archie ja hänen kaksi
skottilaista ystäväänsä, sir Reginald ja sir Filip.

Viime päivinä ei sir Archie ollut käynyt hänen luonaan, ja Elsa


ihastui nähdessään hänet. Ensin hänen teki mieli huutaa olevansa
ihan hänen lähellään, mutta sitte hän tuli ajatelleeksi, että siinä
poisjäämisessä oli jotain outoa, ja hän olikin vaiti. Eihän tiedä vaikka
hän olisi rakastunut toiseen, Elsa ajatteli. Ehkäpä hänellä nytkin on
juuri se mielessään.

Sir Archie istui näet hiukan muista erillään. Hän vaan äänettömänä
tähysti eteensä eikä juonut. Hän ei ottanut osaa toisten
keskusteluun, ja kun hänelle jotakin virkettiin, niin hän ei edes
huolinut vastata.

Elsa kuuli, että toiset koettivat saada häntä hauskemmalle päälle.


He utelivat miksi hän ei juonut. Neuvoivatpa sitäkin, että hän
ratokseen menisi juttelemaan Elsa neidin kanssa.
»Älkää te minusta huolehtiko», sir Archie sanoi. »Toinen minun nyt
on mielessäni. Se se alati häilyy silmäini edessä, ja sen ääni alati
korvissani kuiskaa.»

Ja Elsa näki sir Archien silmäin herkeämättä katsovan yhteen


kellarin paksuista katonkannatuspylväistä. Nyt vasta hän myöskin
huomasi, että hänen kasvinsisarensa seisoi tuon pylvään vieressä ja
katseli sir Archieta. Hän seisoi aivan liikahtamatta niin liki pylvästä,
ettei häntä harmaassa puvussaan ollut helppo siitä erottaa.

Elsa seisoi ihan hiljaa ja katsoi huoneeseen. Hän näki, että hänen
kasvinsisarensa sir Archien edessä piti silmiään auki. Elsan
seurassa hän ei ollut yhtään kertaa nostanut silmiään maasta.

Muuta kammottavaa hänessä ei ollut kuin ne silmät. Elsa näki, että


ne olivat murtuneet ja sameat. Katse niissä oli eloton, eikä valo niistä
enää heijastunut.

Hetken kuluttua sir Archie puhkesi uudestaan vaikeroimaan:


»Hänet minä näen alati. Hän seuraa minua kaikkialle mihin menen.»

Hän ei hetkeksikään kääntänyt katsettaan pois pylväästä, jonka


vieressä kuollut seisoi. Mutta Elsa arvasi, ettei hän kuollutta nähnyt.
Ei sir Archie puhunut hänestä, vaan jostakin toisesta joka alati oli
hänen mielessään.

Elsa seisoi yhä seinäaukolla ja seurasi kaikkea mitä tapahtui. Hän


ajatteli, että ennen kaikkea hän tahtoi tietää, kuka se oli jota sir
Archie muisteli niin herkeämättä.

Äkkiä hän huomasi kuolleen siirtyneen sir Archien viereen penkille


ja kuiskuttelevan hänen korvaansa.
Mutta sir Archie ei vieläkään tiennyt hänen olevan niin lähellä, että
todella saattoi kuiskuttaa hänen korvaansa. Hän tunsi sen
läheisyyden vaan siitä hirveästä tuskasta, joka hänelle yhtäkkiä tuli.

Elsa näki, että kun kuollut oli pari silmänräpäystä istunut ja


kuiskaillut, niin sir Archie painoi päänsä käsien väliin ja itki: »Voi, kun
en olisi ikinä löytänyt sitä nuorta neitoa!» hän sanoi. »En kadu
mitään muuta kuin etten päästänyt sitä neitosta pakoon, kun hän
pyysi.»

Molemmat skottilaiset lakkasivat juomasta ja kääntyivät säikähtyen


katsomaan sir Archieta, joka äkkinäisessä katumuspuuskassa näin
menetti koko miehuutensa. He istuivat kotvan aikaa neuvottomina,
Vaan sitte toinen heistä hoiperteli tiskin luo, otti siitä isoimman
juomasarven ja täytti sen punaviinillä. Sen tehtyään hän astui sir
Archien eteen, löi häntä olalle ja sanoi: »Juo, veikko! Vielä Aarne
herran rahoja riittää. Niin kauvan kun on varaa hankkia tämänlaista
viiniä, ei surun pidä meistä valtaa saaman.»

Mutta samassa kun tämä oli sanottu: »Juo, veikko! Vielä Aarne
herran rahoja riittää», silloin Elsa näki kuolleen nousevan penkiltä ja
katoavan.

Ja samassa Elsa näki edessään kolme miestä, joilla oli suuret


parrat ja karvapäälliset nahkapuvut ja jotka tappelivat Aarne herran
kanssa. Ja nyt hän näki että ne olivat samat miehet, jotka istuivat
kellarisalissa: sir Archie, sir Filip ja sir Reginald.

3.

You might also like