Introduction to Computer Science using Java

This is a first course in Computer Science using the programming language Java. It covers the fundamentals of programming and of computer science.

For maximum benefit, study these notes interactively, thinking about and answering the question at the bottom of each page. There are about 20 pages per chapter. If you spend about 3 minutes per page each chapter will take about 60 minutes, or longer if you copy and run some of the programs. If you are a beginning programmer, plan on spending more than a month with this.

These notes assume that you have the Java version 5.0 or later from Sun Microsystems, Inc. at java.sun.com and a text editor such as Notepad. They may be used with more sophisticated environments, as well. For more about these notes check the frequently asked questions.

Best viewed at 800 x 600 or higher

This downloaded zip-file version of the notes does not contain the audio portion.

Part 1: Hardware and Software

     

Chapter 1

Computer Systems

Quiz

Flash Cards

 

Chapter 2

Analog and Binary Signals

Quiz

Flash Cards

 

Chapter 3

Computer Memory

Quiz

Flash Cards

 

Chapter 4

The Processor

Quiz

Flash Cards

 

Part 2: Running Java Programs

 

Chapter 5

Introduction to Java

Review

 

 

Chapter 6

Small Java Programs

Review

 

 

Chapter 7

How to Run the Example Programs

Review

 

 

Part 3: Data

 

Chapter 8

Primitive Data

Quiz

Exercises and Flash Cards

 

Chapter 9A

Variables and the Assignment Statement

Quiz

Exercises

 

Chapter 9B

Expressions and Arithmetic Operators

Quiz

Exercises

 

Chapter 9C

Object Data

Quiz

Exercises

 

Chapter 10

Input and Output

Review

Exercises

 

Chapter 11

Floating Point

Review

Exercises

 

Part 4: Branches and Loops

 

Chapter 12

The if Statement

Quiz

Exercises

 

Chapter 13

The Single Branch if Statement

Quiz

Exercises

 

Chapter 14

Boolean Expressions

Review

Exercises

 

Chapter 15

Loops and the while statement

Review

Exercises

 

Chapter 16

Counting Loops

Quiz

Exercises

 

Chapter 17

Nesting Loops and Ifs

Review

Exercises

 

Chapter 18

Sentinel-controlled Loops

Review

Exercises

 

Chapter 19

Result-controlled Loops

Quiz

Exercises

 

Chapter 20

Random Numbers

Quiz

Exercises and Review

 

Part 5: File Input and Output

 

Chapter 21

Files and File Redirection

Review

Exercises

 

Chapter 22

Reading Data with File Redirection

Review

Exercises

 

Chapter 23

I/O using Scanner and PrintStream

Review

Exercises

 

Chapter 24

File Input Techniques

Review

Exercises

 

Chapter 24B

Formatted Output

Quiz

Exercises

 

Part 6: Object Oriented Programming

 

Chapter 25 

Objects

Quiz

 

 

Chapter 26

Object References

Quiz

 

 

Chapter 27

More about Objects and Classes

Review

 

 

Chapter 28

Method Parameters

Review

 

 

Chapter 29

Strings and Object References

Quiz

Exercises

 

Chapter 29B

More about Strings

Quiz

Exercises

 

Chapter 30

Defining your own Classes

Review    

Exercises

 

Chapter 31

Class Design Example (miles per gallon)

Review

Exercises

 

Chapter 32

Class Design Example (checking account)

Review

Exercises

 

Chapter 33

Encapsulation and Visibility Modifiers

Quiz

Exercises

 

Chapter 34A

Parameters, Overloading, Local Variables

Review

 

 

Chapter 34B

Object Parameters

Quiz

 

 

Chapter 35

Objects that Contain Objects

Review

Exercises

 

Part 7: Applets and Graphics

 

Chapter 36 

Applets

Quiz    

Exercises

 

Chapter 37 

Applet Examples

Quiz

Exercises

 

Chapter 38 

More Applet Examples

Quiz

Exercises

 

Part 8: More Java Features

 

Chapter 39 

Increment, Decrement, and Assignment Operators

Quiz    

 

 

Chapter 40 

Boolean Expressions and Short-circuit Operators

Quiz    

 

 

Chapter 40B 

Truth Tables and De Morgan's Laws

Review    

 

 

Chapter 41 

The for Statement

Quiz    

Exercises

 

Chapter 42 

More about the for Statement

Quiz    

Exercises

 

Chapter 43 

The Conditional Operator and the switch Statement

Quiz    

Exercises

 

Chapter 44 

The do Statement

Quiz    

Exercises

 

Part 9: Arrays

 

Chapter 46 

Arrays

Quiz    

Exercises

 

Chapter 47 

Common Array Algorithms

Quiz    

Exercises

 

Chapter 48 

Arrays as Parameters

Review    

Exercises

 

Chapter 49A 

Methods that Change Arrays

Quiz    

 

 

Chapter 49B 

Arrays of Objects and Linear Search

Quiz    

Exercises

 

Chapter 49C 

Two-dimensional Arrays

Quiz    

Exercises

 

Chapter 49D 

StringBuffers

Quiz    

Exercises

 

Part 10: Advanced Object Oriented Programming

 

Chapter 50 

Inheritance

Quiz    

 

 

Chapter 51 

Abstract Classes and Polymorphism

Quiz    

 

 

Chapter 52 

More about Polymorphism

Quiz    

 

 

Chapter 53 

Interfaces

Quiz    

 

 

Chapter 53B 

The Comparable Interface

Quiz    

Exercises

 

Chapter 54 

ArrayLists and Iterators

Quiz    

 

 

Part 11: Graphical User Interface Programming

 

Chapter 55 

GUI Programming

Quiz    

 

 

Chapter 56 

JFrames

Quiz    

 

 

Chapter 57 

Adding Buttons to a JFrame

Quiz    

Exercises

 

Chapter 59

Buttons and Action Events

Quiz    

Exercises    

 

Chapter 60 

JTextFields and JLabels

Quiz    

Exercises    

 

Chapter 61 

GUI Applications

Quiz    

Exercises    

 

Chapter 62 

JPanel and BoxLayout

Quiz    

 

 

Chapter 63 

Radio Buttons and BorderLayout

 

Exercises    

 

Chapter 64 

JSliders and Change Events

 

Exercises    

 

Part 12: Recursion

 

Chapter 70 

Recursion

Quiz    

Exercises

 

Chapter 71 

Recursion in Java

Quiz    

Exercises

 

Chapter 72 

Examples of Recursion

Quiz    

Exercises

 

Chapter 73 

More Recursion

Quiz    

Exercises

 

Chapter 74 

Recursion with Graphics

   

Exercises

 

Part 13: Exceptions and IO Streams

 

Chapter 80 

Exceptions and Errors

Quiz    

Exercises

 

Chapter 81 

More about Exceptions

Quiz    

Exercises

 

Chapter 82 

Input and Output Streams

Quiz    

   

 

Chapter 83 

Writing Text Files

Quiz    

Exercises

 

Chapter 84 

Reading Text Files

Quiz    

Exercises

 

Chapter 85 

Writing Binary Files

Quiz    

Exercises

 

Chapter 86 

Reading Binary Files

Quiz    

Exercises

 

Chapter 87 

The File Class

Quiz    

Exercises

Appendix

 

Index


·         Homepage             

·         Many thanks to Bradley Kjell, Central Connecticut State University, January 2008