图书前言

Who Should Read This Book

This book teaches Java programming with a focus on object-oriented programming using the Java programming language. Designed for readers with no prior knowledge in computer programming, this book is unassuming and is most suitable for teaching Java at the undergraduate level. Complete source code is provided in every example and where applicable, screen-shots are used to as an added help for readers in their practical exercises.

Topic Covered in This Book

Topics covered include: the Java programming environment; the Java language components which include variables; data structures; data types and their declaration; expressions, statements, and operators; program flow control mechanisms; arrays; methods; inputs and outputs; class and objects; file handling; single class inheritance; encapsulation; polymorphism; abstract class, abstract method, inner class, method overriding, multiple class inheritance and interface. This book also covers the Java Application Programming Interface (API)-a rich Java class library.

How This Book Is Organized

This book is organized into fourteen chapters with each chapter building on what have been covered in the previous chapters. Each chapter is designed workshops and exercises. Workshops are practices with complete solutions provided while exercises are intended for readers to try out writing object-oriented programs in Java on their own.

Chapter 1: The Java Programming Environment

This chapter prepares the readers for Java programming with instructions on how to set up the Java programming environment.

Chapter 2: The Java Language Components

This chapter defines the vocabulary of the Java language and explains how the words and symbols can be put together to form the basic program structure in Java. 

Chapter 3: Expressions and Statements

 Preface                          Java Programming                          This chapter explains the structure of a Java expression and how it can be used in conjunction with a semi-colon to form statements, the basic executable component of Java. 

Chapter 4: Program Flow Controls

This chapter explains how to add program flow control mechanisms in a Java program. Statements can be put together and executed sequentially using the Sequence construct, selectively using the Selection construct, and repetitively using the Iteration construct.  

Chapter 5: Arrays

This chapter explains the concept of an array as a data structure for storing and manipulating data of the same type as a collection. Details on how to manipulate a one-dimensional and two-dimensional array are included in this chapter. 

Chapter 6: Methods

This chapter explains how a Java program can be more structured with the use of method-a collection of data and statements for performing a task.

Chapter 7: Class and Objects

Java is an object-oriented programming language. This chapter explains the concept of class and object and how to write Java programs using the object-oriented programming paradigm. 

Chapter 8: The Java Application Programming Interface (API)

Java is a very small language with only 46 reserved keywords but it is extended with a library of Java Application Programming Interfaces (Java APIs). It is from the Java APIs that the power of Java is felt. This chapter introduces the Java API and its accompanying documentation and explains how the Java API can be used to solve complicated problems in Java. 

Chapter 9: Inputs and Outputs

This chapter explains how data input and output can be carried out in Java. 

Chapter 10: File Handling

This chapter discusses how to read and write data from text and binary files. 

Chapter 11: Inheritance

Inheritance is an object-oriented mechanism for realizing software reuse. A subclass in single class inheritance can inherit properties from a superclass. When a subclass inherits properties from more than one superclass, we have multiple class inheritance. This chapter discusses concepts related to single class inheritance. 

Chapter 12: Encapsulation

Encapsulation is the bringing together of data fields and methods into an object definition with the effect of hiding the internal workings of the data fields and methods from the users of the object. Any direct access and updates to the object¡¯s constituents is not permissible and changes to the data fields can only be carried out indirectly via a set of publicly available methods. This chapter focuses on data field encapsulation and class encapsulation.  

Chapter 13: Polymorphism

The ability of objects of different subclass definition to respond to the same message is polymorphism. Polymorphism is only possible with dynamic binding-the capability of determining which method implementation to use for a method at runtime. This chapter explains the concept of polymorphism and its peripheral object-oreinted programming concepts. 

Chapter 14: Interface

Sometimes it is necessary to derive a subclass from several classes but the Java extends keyword does not allow for more than one parent class. With interfaces, multiple class inheritance is possible. This chapter explains and shows how to use the Java interface construct to realize multiple class inheritance.

Chapter 15: Sorting, Searching and Recursion

This chapter discusses three topics commonly found in Java programming. They include: Sorting, Searching, and Recursion.

Enjoy!

Danny